{"id":530,"date":"2014-03-07T17:36:43","date_gmt":"2014-03-07T23:36:43","guid":{"rendered":"https:\/\/www.galador.org\/blog\/?p=530"},"modified":"2018-05-01T22:57:07","modified_gmt":"2018-05-02T04:57:07","slug":"select-analogy","status":"publish","type":"post","link":"https:\/\/www.galador.org\/blog\/select-analogy\/","title":{"rendered":"SELECT * Analogy"},"content":{"rendered":"<p>The DBAs at the company I work for sent out a mass email this morning &#8220;reminding&#8221; developers that using SELECT * is a <a href=\"http:\/\/stackoverflow.com\/questions\/3639861\/why-is-select-considered-harmful\">bad idea<\/a>. One of my friends, who usually asks me about database questions was confused about one part of the email:<\/p>\n<blockquote><p>If  implementing these changes for an existing application, the percentage decreases will be <strong>off the time to process columns<\/strong> and not necessarily off the total currently used by the SQL statement. <\/p><\/blockquote>\n<p>And I came up with what I thought was a pretty good analogy:<\/p>\n<blockquote><p>Let&#8217;s pretend the database table is a grocery store, and you need to buy ingredients so you can bake a cake.<\/p>\n<p>&#8220;SELECT *&#8221; would be like taking every single product in the store home and then figuring out which ingredients you actually need to make a cake.<\/p>\n<p>Selecting individual columns would be taking your recipe with you and getting only the ingredients you need.<\/p>\n<p>It still might take you a while to go through the store, especially if it&#8217;s one of those huge mega-marts (a.k.a, a really big query with lots of joins) to find the ingredients you need, but only getting the products you need will make things a lot faster when you get home.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The DBAs at the company I work for sent out a mass email this morning &#8220;reminding&#8221; developers that using SELECT * is a bad idea. One of my friends, who usually asks me about database questions was confused about one part of the email: If implementing these changes for an existing application, the percentage decreases &hellip; <a href=\"https:\/\/www.galador.org\/blog\/select-analogy\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">SELECT * Analogy<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,61],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","hentry","category-corporate-america","category-database"],"_links":{"self":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":3,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":571,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/posts\/530\/revisions\/571"}],"wp:attachment":[{"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.galador.org\/blog\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}