{"id":49105,"date":"2016-05-25T08:03:48","date_gmt":"2016-05-25T15:03:48","guid":{"rendered":"https:\/\/redfindevelop.wpengine.com\/blog\/?p=49105"},"modified":"2020-10-05T13:11:58","modified_gmt":"2020-10-05T20:11:58","slug":"how-hibernate-lazy-loading-nearly-killed-our-email","status":"publish","type":"post","link":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/","title":{"rendered":"How Hibernate&#8217;s Lazy Loading Nearly Killed Our Email"},"content":{"rendered":"<h3>Our Data Addiction<\/h3>\n<p>On a typical Saturday afternoon in the height of the summer home-buying season, Redfin will send millions of listing update emails and push notifications to our users.<\/p>\n<p>One of our biggest advantages is our ability to send these notifications within moments of an event appearing in the Multiple Listing Service (<a href=\"https:\/\/en.wikipedia.org\/wiki\/Multiple_listing_service\" target=\"_blank\" rel=\"noopener noreferrer\">MLS<\/a>) feed, the data source real estate agents use to put new homes on the market. In hot markets like <a href=\"https:\/\/redfin.com\/city\/17151\/CA\/San-Francisco\" target=\"_blank\" rel=\"noopener noreferrer\">San Francisco<\/a> or <a href=\"https:\/\/redfin.com\/city\/16163\/WA\/Seattle\" target=\"_blank\" rel=\"noopener noreferrer\">Seattle<\/a>, this timing can be critical: putting in a strong offer within hours of the initial listing can make the difference between securing a dream home and losing it in a bidding war.<\/p>\n<p>Many of our customers (hundreds of thousands in fact) opt to receive daily digests rather than instant notifications throughout the day. And when these daily emails \u2014 unique to each user \u2014 are generated in the morning, our machines can be kept busy for hours trying to fetch all the required data to send them out.<\/p>\n<p>Under extreme conditions, the implications of this excessive workload are twofold:<\/p>\n<ol>\n<li>Other jobs (listing importers, search indexers, etc.) can get backed up while the daily email job hogs resources.<\/li>\n<li>Users\u2019 emails can get delayed, potentially hours after they would normally expect them.<\/li>\n<\/ol>\n<p>In early 2015 \u2014 at a time when our email jobs relied almost entirely on batch-oriented operations \u2014 we began to observe exactly these two frightening scenarios:<\/p>\n<figure id=\"media-49115\"><\/figure>\n<figure id=\"media-49116\"><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone\" src=\"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Pre-Improvement.png\" alt=\"Formatting Time Per Email (pre-improvement)\" width=\"1096\" height=\"761\" \/><\/figure>\n<p>This is the kind of a chart you <em>don\u2019t<\/em> want to see. Our email formatting time had inexplicably inflated threefold in just two months, and our team had <em>no internal changes<\/em> to point to, no recent hardware modifications \u2014 nothing that could explain the dangerous upward trend.<\/p>\n<p>And then we found our critical dependency.<\/p>\n<h3>The Insidious Helper<\/h3>\n<p>As it turned out, helper methods and data services that our team was using to build emails were also being used by other teams to render web pages. And these services were quickly evolving behind the scenes to accommodate the growing needs of <a href=\"https:\/\/redfin.com\/blog\/\" target=\"_blank\" rel=\"noopener noreferrer\">Redfin.com<\/a>: <a href=\"https:\/\/redfin.com\/blog\/2015\/04\/redfin-shared-search-makes-it-easy-for-spouses-agents-and-parents-to-work-together-on-a-house-hunt.html\" target=\"_blank\" rel=\"noopener noreferrer\">Shared Search<\/a>, <a href=\"https:\/\/redfin.com\/blog\/2015\/07\/redfin-book-it-now.html\" target=\"_blank\" rel=\"noopener noreferrer\">Book It Now<\/a>, and more cool new features were requiring more and more data and thus incurring additional latency with every database access.<\/p>\n<p>Typically an added latency of a few milliseconds would go unnoticed in the webapp&#8211;concealed by the much longer time it takes to download and render JavaScript on the client, but our email jobs were feeling the pain. Big time.<\/p>\n<p>The problem originated from code like this:<\/p>\n<pre class=\"lang:java decode:true\">home.isTourableByRedfin(user) \/\/ Can Redfin take this user on a tour of this home?<\/pre>\n<p>Because Redfin uses <a href=\"http:\/\/hibernate.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hibernate<\/a> to abstract away the SQL, we tend to not notice what\u2019s really happening when we call this function \u2014 until we look.<\/p>\n<p>While at the surface, the function was just checking some fields on the <span class=\"lang:java decode:true crayon-inline \">home<\/span> and <span class=\"lang:java decode:true crayon-inline \">user<\/span> objects to determine if the home was tourable, under the hood there was a lot more going on:<\/p>\n<pre class=\"lang:java decode:true\">\/\/ Get this user\u2019s Shared Search group.\nSharedSearchGroup sharedSearchGroup = user.getSharedSearchGroup();\n\n...\n\n\/\/ Get agents for the Shared Search group.\nSet&lt;Agent&gt; agents = new HashSet&lt;&gt;();\nfor (User cobuyer : sharedSearchGroup.getCobuyers()) {\n    Person person = cobuyer.getPerson();\n    TourRequest tourRequest = tourService.getPendingTour(person);\n    agents.add(tourRequest.getAgent());\n}<\/pre>\n<p>As Redfin had recently introduced <a href=\"https:\/\/redfin.com\/blog\/2015\/04\/redfin-shared-search-makes-it-easy-for-spouses-agents-and-parents-to-work-together-on-a-house-hunt.html\" target=\"_blank\" rel=\"noopener noreferrer\">Shared Search<\/a>, we were no longer just interested in whether we could take you on a tour but if we could take <em>your co-buyer<\/em> on a tour too.<\/p>\n<p>Unfortunately, every getter in the block of code above was lazily loading data via round trips to the database, thus incurring tremendous costs when executed on the order of hundreds of thousands of users at once.<\/p>\n<p>The solution was to change the data service that prefetches our User objects to eagerly fetch the data we <em>know<\/em> the <span class=\"lang:java decode:true crayon-inline \">isTourableByRedfin<\/span> method will need during email formatting.<\/p>\n<p>To accomplish this we modify our data service to include <a href=\"https:\/\/docs.jboss.org\/hibernate\/orm\/3.5\/javadocs\/org\/hibernate\/Criteria.html\" target=\"_blank\" rel=\"noopener noreferrer\">Hibernate criteria<\/a> that request that specific fields be eagerly fetched. For example:<\/p>\n<pre class=\"lang:java decode:true\">\/\/ Return a Shared Search Group with the cobuyers eagerly fetched.\npublic List&lt;SharedSearchGroup&gt; getSharedSearchGroupsWithCobuyers(\n    Collection&lt;Long&gt; sharedSearchGroupIds) {\n        return getBlankCriteria()\n            .createAlias(\"cobuyers\", \"c\", JoinFragment.INNER_JOIN)\n            .setFetchMode(\"c\", FetchMode.JOIN)\n            .add(Restrictions.in(\"id\", ids))\n            .list();\n}<\/pre>\n<p>The above statement will fetch all the cobuyers in a SharedSearchGroup in addition to the SharedSearchGroup itself. By doing so, we avoid a round trip to the database when <span class=\"lang:java decode:true crayon-inline \">sharedSearchGroup.getCobuyers()<\/span> is called since the cobuyers are already in memory.<\/p>\n<p>When we rolled these changes out to production, the results were staggering:<\/p>\n<figure id=\"media-49115\"><img decoding=\"async\" src=\"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png\" alt=\"Formatting Time Per Email (post-improvement)\" \/><\/figure>\n<p>Within minutes of deploy, we watched our formatting time plummet back to safe levels, exhibiting a 70% performance improvement on average. And most importantly, our customers were getting their notifications on time, right as we swung into the busiest time of the annual real estate cycle.<\/p>\n<h3>A Case for Isolation and Data Frugality<\/h3>\n<p>Walking away from this situation, it would be easy to argue in favor of eagerly fetching data wherever possible. After all, had Redfin\u2019s data services done so, we never would have run into this performance wall in the first place.<\/p>\n<p>However, we choose to fetch data lazily for a reason:<\/p>\n<ul>\n<li>Doing so yields lower memory utilization because we\u2019re only loading the fields we need.<\/li>\n<li>Redfin\u2019s database hardware&#8211;the storage and the connections&#8211;are fast. Like really fast. So the cost of making a round trip to the database is pretty small for the typical webapp use-case.<\/li>\n<li>Lazy fetching prevents new fields that reference other tables from incurring unexpected costs due to new table joins.<\/li>\n<\/ul>\n<p>Unfortunately, this approach seems at odds with the lessons learned from our brief, but frightening, ride on the email-formatting rollercoaster of Spring 2015.<\/p>\n<p>The compromise is not to build out our own email-specific variants of Redfin helper methods but rather to minimize the scope of the database transaction. <strong>We fetch <em>only<\/em> the data we want, let Hibernate hydrate our Java POJOs, and then promptly close the database connection<\/strong> so that no secret return visits to the database may occur without us knowing it. (Should that happen, we would see a Hibernate error immediately in our test environment.)<\/p>\n<p>From there \u2014 with the database connection severed \u2014 we pipe our minimally hydrated data through our notifications pipeline without having to worry that some other team\u2019s new feature will mysteriously slow down our email as it did more than a year ago.<\/p>\n<p>A final lesson here is the importance of regular, automated performance testing. While we may do our best to design a system resilient to external changes, we are still susceptible to the inevitable performance anomaly. Therefore, in the wake of this experience, our team has set up the instrumentation and alarming required to detect these anomalies as they happen \u2014 and act on them immediately \u2014 before our customers are impacted.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using Hibernate\u2019s FetchMode to improve performance in data-hungry applications <\/p>\n","protected":false},"author":13156,"featured_media":49115,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[57],"tags":[78],"dashboard":[],"coauthors":[],"class_list":["post-49105","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-company-news","tag-career"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v24.7 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How Hibernate&#039;s Lazy Loading Nearly Killed Our Email<\/title>\n<meta name=\"description\" content=\"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How Hibernate&#039;s Lazy Loading Nearly Killed Our Email\" \/>\n<meta property=\"og:description\" content=\"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/\" \/>\n<meta property=\"og:site_name\" content=\"Redfin Real Estate News\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/redfin\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-25T15:03:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-05T20:11:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1478\" \/>\n\t<meta property=\"og:image:height\" content=\"761\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Daniel Ehrman\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@redfin\" \/>\n<meta name=\"twitter:site\" content=\"@redfin\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Daniel Ehrman\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/\"},\"author\":{\"name\":\"Daniel Ehrman\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#\\\/schema\\\/person\\\/f81701acb1d123ba64cff442a00c1874\"},\"headline\":\"How Hibernate&#8217;s Lazy Loading Nearly Killed Our Email\",\"datePublished\":\"2016-05-25T15:03:48+00:00\",\"dateModified\":\"2020-10-05T20:11:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/\"},\"wordCount\":1016,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.redfin.com/news\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/Post-Improvement.png\",\"keywords\":[\"Career\"],\"articleSection\":[\"Company News\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#respond\"]}],\"copyrightYear\":\"2016\",\"copyrightHolder\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/\",\"url\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/\",\"name\":\"How Hibernate's Lazy Loading Nearly Killed Our Email\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.redfin.com/news\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/Post-Improvement.png\",\"datePublished\":\"2016-05-25T15:03:48+00:00\",\"dateModified\":\"2020-10-05T20:11:58+00:00\",\"description\":\"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.redfin.com/news\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/Post-Improvement.png\",\"contentUrl\":\"https:\\\/\\\/www.redfin.com/news\\\/wp-content\\\/uploads\\\/2016\\\/05\\\/Post-Improvement.png\",\"width\":1478,\"height\":761},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/how-hibernate-lazy-loading-nearly-killed-our-email\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.redfin.com/news\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How Hibernate&#8217;s Lazy Loading Nearly Killed Our Email\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#website\",\"url\":\"https:\\\/\\\/www.redfin.com/news\\\/\",\"name\":\"Redfin Real Estate News\",\"description\":\"The latest real estate news and research from technology-powered residential real estate company, Redfin.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.redfin.com/news\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#organization\",\"name\":\"Redfin\",\"url\":\"https:\\\/\\\/www.redfin.com/news\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.redfin.com\\\/news\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/Redfin-News-Logo.png\",\"contentUrl\":\"https:\\\/\\\/www.redfin.com\\\/news\\\/wp-content\\\/uploads\\\/2020\\\/10\\\/Redfin-News-Logo.png\",\"width\":1100,\"height\":235,\"caption\":\"Redfin\"},\"image\":{\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/redfin\",\"https:\\\/\\\/x.com\\\/redfin\",\"https:\\\/\\\/www.instagram.com\\\/redfinrealestate\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/redfin\",\"https:\\\/\\\/www.pinterest.com\\\/redfin\\\/\",\"https:\\\/\\\/en.wikipedia.org\\\/wiki\\\/Redfin\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.redfin.com/news\\\/#\\\/schema\\\/person\\\/f81701acb1d123ba64cff442a00c1874\",\"name\":\"Daniel Ehrman\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g58a4690c614027fff849a58eb5e00d75\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g\",\"caption\":\"Daniel Ehrman\"},\"description\":\"I'm a full stack dev on Redfin's Notifications team. I come from a background in microprocessor design \u2014 before I happily traded annual tape-outs for daily deploys.\",\"url\":\"https:\\\/\\\/www.redfin.com/news\\\/author\\\/daniel-ehrmanredfin-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How Hibernate's Lazy Loading Nearly Killed Our Email","description":"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/","og_locale":"en_US","og_type":"article","og_title":"How Hibernate's Lazy Loading Nearly Killed Our Email","og_description":"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.","og_url":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/","og_site_name":"Redfin Real Estate News","article_publisher":"https:\/\/www.facebook.com\/redfin","article_published_time":"2016-05-25T15:03:48+00:00","article_modified_time":"2020-10-05T20:11:58+00:00","og_image":[{"width":1478,"height":761,"url":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png","type":"image\/png"}],"author":"Daniel Ehrman","twitter_card":"summary_large_image","twitter_creator":"@redfin","twitter_site":"@redfin","twitter_misc":{"Written by":"Daniel Ehrman","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#article","isPartOf":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/"},"author":{"name":"Daniel Ehrman","@id":"https:\/\/www.redfin.com\/news\/#\/schema\/person\/f81701acb1d123ba64cff442a00c1874"},"headline":"How Hibernate&#8217;s Lazy Loading Nearly Killed Our Email","datePublished":"2016-05-25T15:03:48+00:00","dateModified":"2020-10-05T20:11:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/"},"wordCount":1016,"commentCount":0,"publisher":{"@id":"https:\/\/www.redfin.com\/news\/#organization"},"image":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#primaryimage"},"thumbnailUrl":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png","keywords":["Career"],"articleSection":["Company News"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#respond"]}],"copyrightYear":"2016","copyrightHolder":{"@id":"https:\/\/www.redfin.com\/news\/#organization"}},{"@type":"WebPage","@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/","url":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/","name":"How Hibernate's Lazy Loading Nearly Killed Our Email","isPartOf":{"@id":"https:\/\/www.redfin.com\/news\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#primaryimage"},"image":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#primaryimage"},"thumbnailUrl":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png","datePublished":"2016-05-25T15:03:48+00:00","dateModified":"2020-10-05T20:11:58+00:00","description":"If your application is accessing data spread across multiple tables, reassessing your FetchMode settings could save you from an avoidable performance trap.","breadcrumb":{"@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#primaryimage","url":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png","contentUrl":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2016\/05\/Post-Improvement.png","width":1478,"height":761},{"@type":"BreadcrumbList","@id":"https:\/\/www.redfin.com\/news\/how-hibernate-lazy-loading-nearly-killed-our-email\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redfin.com\/news\/"},{"@type":"ListItem","position":2,"name":"How Hibernate&#8217;s Lazy Loading Nearly Killed Our Email"}]},{"@type":"WebSite","@id":"https:\/\/www.redfin.com\/news\/#website","url":"https:\/\/www.redfin.com\/news\/","name":"Redfin Real Estate News","description":"The latest real estate news and research from technology-powered residential real estate company, Redfin.","publisher":{"@id":"https:\/\/www.redfin.com\/news\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redfin.com\/news\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redfin.com\/news\/#organization","name":"Redfin","url":"https:\/\/www.redfin.com\/news\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redfin.com\/news\/#\/schema\/logo\/image\/","url":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2020\/10\/Redfin-News-Logo.png","contentUrl":"https:\/\/www.redfin.com\/news\/wp-content\/uploads\/2020\/10\/Redfin-News-Logo.png","width":1100,"height":235,"caption":"Redfin"},"image":{"@id":"https:\/\/www.redfin.com\/news\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/redfin","https:\/\/x.com\/redfin","https:\/\/www.instagram.com\/redfinrealestate\/","https:\/\/www.linkedin.com\/company\/redfin","https:\/\/www.pinterest.com\/redfin\/","https:\/\/en.wikipedia.org\/wiki\/Redfin"]},{"@type":"Person","@id":"https:\/\/www.redfin.com\/news\/#\/schema\/person\/f81701acb1d123ba64cff442a00c1874","name":"Daniel Ehrman","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g58a4690c614027fff849a58eb5e00d75","url":"https:\/\/secure.gravatar.com\/avatar\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/92584c9dd9011e4319d235e3a9a902502d7a408d6c81491eaff0386f915329dc?s=96&d=wp_user_avatar&r=g","caption":"Daniel Ehrman"},"description":"I'm a full stack dev on Redfin's Notifications team. I come from a background in microprocessor design \u2014 before I happily traded annual tape-outs for daily deploys.","url":"https:\/\/www.redfin.com\/news\/author\/daniel-ehrmanredfin-com\/"}]}},"_links":{"self":[{"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/posts\/49105","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/users\/13156"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/comments?post=49105"}],"version-history":[{"count":0,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/posts\/49105\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/media\/49115"}],"wp:attachment":[{"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/media?parent=49105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/categories?post=49105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/tags?post=49105"},{"taxonomy":"dashboard","embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/dashboard?post=49105"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.redfin.com\/news\/wp-json\/wp\/v2\/coauthors?post=49105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}