{"id":15,"date":"2004-07-08T10:30:04","date_gmt":"2004-07-08T17:30:04","guid":{"rendered":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/?p=15"},"modified":"2004-07-08T10:30:04","modified_gmt":"2004-07-08T17:30:04","slug":"database-operation-complexity-reference","status":"publish","type":"post","link":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/2004\/07\/08\/database-operation-complexity-reference\/","title":{"rendered":"Database Operation Complexity Reference"},"content":{"rendered":"<p>I mentioned this <a href=\"\/2004\/06\/distributed_dat.html\">previously<\/a>, but I&#8217;ve been reading &#8220;Principles of Distributed Database Systems.&#8221;  I&#8217;m enjoying it, and it&#8217;s helping me solidify many of the concepts that I apply daily in my capacity as a Principal BI Solutions consultant.  Database theory, and specifically as it relates to tuning is part of any professionals work with Oracle.  We&#8217;ve all deciphered the performance implications and clues for improvements from <a href=\"http:\/\/www.google.com\/search?hl=en&amp;lr=&amp;ie=UTF-8&amp;q=%22EXPLAIN+PLAN%22+oracle&amp;btnG=Search\">EXPLAIN PLAN<\/a>.  I&#8217;ve always been told you want to be able to give Oracle the clues\/configurations to enable filter of results (selection) before joining.  It always made sense but I had never understood fully the concepts behind these recommendations.  Until now&#8230;<\/p>\n<p>\nI don&#8217;t espouse to understand all of the complexities behind these issues but I ran across a great reference chart.  I wanted to post it here along with some numbers for demonstration as a quick reference for any professionals with understanding of quadratic, logarithmic, and linear scales to match those up with the operations we use on a day to day basis.<\/p>\n<p>\nThis is from the book mentioned above, however I&#8217;m sure it&#8217;s rather common knowledge.<\/p>\n<table>\n<tr>\n<td><strong>OPERATION<\/strong><\/td>\n<td><strong>COMPLEXITY<\/strong><\/td>\n<\/tr>\n<tr>\n<td>SELECT<\/td>\n<td rowspan=\"2\"><em>O(n)<\/em><\/td>\n<\/tr>\n<tr>\n<td>PROJECT (without dedup)\t<\/td>\n<\/tr>\n<tr>\n<td>PROJECT (with dedup) <\/td>\n<td rowspan=\"6\"><em>O(n*log n)<\/em><\/td>\n<\/tr>\n<tr>\n<td>GROUP<\/td>\n<\/tr>\n<tr>\n<td>JOIN<\/td>\n<\/tr>\n<tr>\n<td>SEMIJOIN<\/td>\n<\/tr>\n<tr>\n<td>DIVISION<\/td>\n<\/tr>\n<tr>\n<td>SET OPERATORS<\/td>\n<\/tr>\n<tr>\n<td>CARTESIAN PRODUCT<\/td>\n<td><em>O(n&sup2;)<\/em><\/td>\n<\/tr>\n<\/table>\n<p>A quick look at some numbers in the orders mentioned yield the following &#8220;costs&#8221; in n operation times.<\/p>\n<table>\n<tr>\n<td>n<\/td>\n<td>O(n)<\/td>\n<td>O(n*log n)<\/td>\n<td>O(n&sup2;)<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>5<\/td>\n<td>3.49<\/td>\n<td>25<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>10<\/td>\n<td>10<\/td>\n<td>100<\/td>\n<\/tr>\n<tr>\n<td>100<\/td>\n<td>100<\/td>\n<td>200<\/td>\n<td>10000<\/td>\n<\/tr>\n<tr>\n<td>1000<\/td>\n<td>1000<\/td>\n<td>3000<\/td>\n<td>1000000<\/td>\n<\/tr>\n<tr>\n<td>1000000<\/td>\n<td>1000000<\/td>\n<td>6000000<\/td>\n<td>1E+12<\/td>\n<\/tr>\n<\/table>\n<p> Hope this helps provide a useful way to match up the database operations we use on a daily basis with the theoretical cost of such operations.  Cheers!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I mentioned this previously, but I&#8217;ve been reading &#8220;Principles of Distributed Database Systems.&#8221; I&#8217;m enjoying it, and it&#8217;s helping me solidify many of the concepts that I apply daily in my capacity as a Principal BI Solutions consultant. Database theory, and specifically as it relates to tuning is part of any professionals work with Oracle. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,10],"tags":[],"_links":{"self":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts\/15"}],"collection":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":0,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}