{"id":2668,"date":"2019-07-14T16:22:31","date_gmt":"2019-07-14T16:22:31","guid":{"rendered":"https:\/\/nenadnoveljic.com\/blog\/?p=2668"},"modified":"2020-10-08T14:21:01","modified_gmt":"2020-10-08T14:21:01","slug":"io-sort-cost-calculation","status":"publish","type":"post","link":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/","title":{"rendered":"IO Sort Cost Calculation"},"content":{"rendered":"<p>Jonathan Lewis wrote an article about <a href=\"https:\/\/jonathanlewis.wordpress.com\/2019\/06\/06\/scalar-subquery-costing\/\">scalar subquery costing<\/a>. In the course of subsequent experiments we noticed an unusual discrepancy in the IO sort cost for different block sizes. That was also one of the topics in our exchange in the comments of his blog post.<\/p>\n<p>This discrepancy is clearly visible in the sort section of the optimizer trace. See below the excerpts for <span style=\"color:red\">8k<\/span> and <span style=\"color:blue\">32k<\/span> database block sizes, respectively:<\/p>\n<pre><code>SORT ressource         Sort statistics\n      Sort width:         305 Area size:      268288 Max Area size:    53686272\n      Degree:               1\n      <span style=\"color:brown\">Blocks to Sort:<\/span> <span style=\"color:red\">196<\/span> Row size:     16 Total Rows:         100000\n      Initial runs:   2 Merge passes:  1 <span style=\"color:brown\">IO Cost \/ pass:<\/span>        <span style=\"color:red\">108<\/span>\n      <span style=\"color:brown\">Total IO sort cost:<\/span> <span style=\"color:red\">304.000000<\/span>      Total CPU sort cost: 119218158\n      Total Temp space used: 1221000\n\nSORT ressource         Sort statistics\n  Sort width:         306 Area size:      268288 Max Area size:    53686272\n  Degree:               1\n  <span style=\"color:brown\">Blocks to Sort:<\/span> <span style=\"color:blue\">49<\/span> Row size:     16 Total Rows:         100000\n  Initial runs:   2 Merge passes:  1 <span style=\"color:brown\">IO Cost \/ pass:<\/span>         <span style=\"color:blue\">74<\/span>\n  <span style=\"color:brown\">Total IO sort cost:<\/span> <span style=\"color:blue\">123.000000<\/span>      Total CPU sort cost: 139966334\n  Total Temp space used: 1246000<\/code><\/pre>\n<p>The only difference in both tests was the block size. Consequently, <span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> is 4 times higher on the database with the <span style=\"color:red\">8k<\/span> block size. But, the <span style=\"color:brown\"><i>Total IO sort cost<\/i><\/span> is almost three times higher for the <span style=\"color:red\">8k<\/span> database, which doesn&#8217;t seem right, because the data volume is exactly the same. I mean a single IO of <span style=\"color:blue\">32k<\/span> is usually more efficient than 4 IOs of <span style=\"color:red\">8k<\/span>, but by no means by factor three.<\/p>\n<p>This inconsistency prompted further investigation.<\/p>\n<h1>Blocks to Sort<\/h1>\n<p>By simple eyeballing I first identified that <span style=\"color:brown\"><i>Total IO sort cost<\/i><\/span> is the sum of two other values exposed in the sort section in the optimizer trace: <span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> and <span style=\"color:brown\"><i>IO Cost \/ pass<\/i><\/span>:<\/p>\n<p><a name=\"id348225197\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 18px;\"><span class=\"ql-right-eqno\"> (1) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-31a738ce10dd1d3d747fe55e8cec5648_l3.png\" height=\"18\" width=\"417\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#84;&#111;&#116;&#97;&#108;&#92;&#32;&#73;&#79;&#92;&#32;&#115;&#111;&#114;&#116;&#92;&#32;&#99;&#111;&#115;&#116;&#32;&#61;&#32;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#73;&#79;&#92;&#32;&#67;&#111;&#115;&#116;&#32;&#47;&#32;&#112;&#97;&#115;&#115; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p><span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> is the fixed part of the cost calculation. Therefore, it&#8217;s the main contributor to the relatively large difference between the cost calculations for different block sizes.<\/p>\n<p>A more challenging part is to figure out the <span style=\"color:brown\"><i>IO Cost \/ pass<\/i><\/span> calculation, the other summand in the equation <a href=\"#id348225197\">1<\/a>.<\/p>\n<h1>IO Cost \/ pass<\/h1>\n<p>There isn&#8217;t a simple way for cracking the formula for <span style=\"color:brown\"><i>IO Cost \/ pass<\/i><\/span> based on the system statistics, block sizes etc. So I first had to identify Oracle functions participating in the calculation and then deduce the formula by observing their inputs, outputs and values stored in the registers.<\/p>\n<p>This technique almost always yields a result. On the downside, it&#8217;s very time consuming. First, you have to work out the numbers and the arithmetic operations. But then, to interpret this calculation, you need to know where these operands came from, which can recursively create additional layers of investigation.<\/p>\n<p>However, the heuristics based on the general optimizer knowledge can dramatically reduce the research time.<\/p>\n<p>Fortunately, Jonathan had correctly assumed that the calculation depends on the system statistics seek time (IOSEEKTIM) and transfer rate (IOTFRSPEED), which had been set to their default values 10ms and 4k, respectively. So, whenever I observed those numbers somewhere in the registers I reasonably assumed that they had came from the system statistics mentioned. After that, I had to rerun the experiment with changed values to see if the deduced formula still holds.<\/p>\n<p>But first of all, I had to identify the entry point, i.e. a higher level Oracle function involved in the cost calculation.<\/p>\n<h2>kkeSortCosts<\/h2>\n<p>I did that by <a href=\"https:\/\/nenadnoveljic.com\/blog\/enriching-trace-with-call-stacks\/\">enriching trace with call stacks<\/a>, a troubleshooting technique, which I had described in a previous blog post. Basically, I&#8217;m using DTrace for capturing the call stack whenever a string of interest gets written into the trace file:<\/p>\n<pre><code>sudo -u root \/usr\/sbin\/dtrace -p 6178 -s call_stack_trace.d '\"Total\"'\n\nSORT ressource         Sort statistics\n  Sort width:         306 Area size:      268288 Max Area size:    53686272\n  Degree:               1\n  Blocks to Sort: 49 Row size:     16 Total Rows:         100000\n  Initial runs:   2 Merge pas\nlibc.so.1`__write+0xa\na.out`sdbgrfuwf_write_file+0x42\na.out`sdbgrfwf_write_file+0x3a\na.out`dbgtfdFileWrite+0x210\na.out`dbgtfdFileAccessCbk+0x177\na.out`dbgtfWriteRec+0x585\na.out`dbgtRecVAWriteDisk+0xaa\na.out`dbgtTrcVaList_int+0xa96\na.out`dbgtTrc_int+0xa6\na.out`kkeSortCosts+0x2287\na.out`kkesrcCard+0x63\na.out`kkoqbc+0x36eb\na.out`apakkoqb+0xa1\na.out`apaqbdDescendents+0x20e\na.out`apadrv+0xae5\na.out`opitca+0x9ca\na.out`kksFullTypeCheck+0x4c\noracle`rpiswu2+0x20c\na.out`kksLoadChild+0x29f6\na.out`kxsGetRuntimeLock+0x79d<\/code><\/pre>\n<p>As you can see, the function <i>kkeSortCosts<\/i> was the one which produced the trace entries, so I assumed it orchestrates the whole sort cost calculation.<\/p>\n<p>I confirmed that by tracing function calls made by <i>kkeSortCosts<\/i>. <i>kkesIOScaleFactor<\/i> is one of such functions, for which I captured a couple of call stacks:<\/p>\n<pre><code>dtrace -q -n 'pid&#36;target::kkesIOScaleFactor:entry{ ustack(); }' -p 28898\n\na.out`kkesIOScaleFactor\na.out`kkesScaleIO+0xac\na.out`kkeTbScanIOCost+0x24\n...\na.out`kkesIOScaleFactor\na.out`kkesScaleIO+0xac\na.out`kkeSortCosts+0xdec\n...<\/code><\/pre>\n<p>As you can see, there are two different cases where the functions <i>kkesIOScaleFactor<\/i> and <i>kkesScaleIO<\/i> are called. One is the table scan cost calculation (<i>kkeTbScanIOCost<\/i>). The other is the sort cost calculation (<i>kkeSortCosts<\/i>).<\/p>\n<p>Obviously, both <i>kkesScaleIO<\/i> and <i>kkesIOScaleFactor<\/i> are generic functions participating in IO cost calculation; as such, they are undoubtedly worth a more detailed examination.<\/p>\n<h2>kkesScaleIO<\/h2>\n<p>I set up a breakpoint on the exit from <i>kkesScaleIO<\/i> to record the return values which are passed through the XMM0 register.<\/p>\n<pre><code>break kkesScaleIO_RETURN_ADDRESS\ncommands 1\np &#36;xmm0\nbacktrace 3\ncontinue\nend<\/code><\/pre>\n<p>Below are the outputs for <span style=\"color:red\">8k<\/span> and <span style=\"color:blue\">32k<\/span>, respectively:<\/p>\n<pre><code>&#36;3 = {v4_float = {0, 3.171875, 0, 0}, v2_double = {<span style=\"color:red\">54<\/span>, 0}, v16_int8 = {0, 0, 0, 0, 0, 0, 75, 64, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {0, \n    0, 0, 16459, 0, 0, 0, 0}, v4_int32 = {0, 1078657024, 0, 0}, v2_int64 = {4632796641680687104, 0}, uint128 = 4632796641680687104}\n#0  0x00000000104e5dc3 in kkesScaleIO ()\n#1  0x000000000a4e5dbc in kkeSortCosts ()\n#2  0x0000000010550133 in kkesrcCard ()<\/code><\/pre>\n<pre><code>&#36;6 = {v4_float = {0, 3.0390625, 0, 0}, v2_double = {<span style=\"color:blue\">37<\/span>, 0}, v16_int8 = {0, 0, 0, 0, 0, -128, 66, 64, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {\n    0, 0, -32768, 16450, 0, 0, 0, 0}, v4_int32 = {0, 1078099968, 0, 0}, v2_int64 = {4630404104378646528, 0}, \n  uint128 = 4630404104378646528}\n#0  0x00000000104e5dc3 in kkesScaleIO ()\n#1  0x000000000a4e5dbc in kkeSortCosts ()\n#2  0x0000000010550133 in kkesrcCard ()<\/code><\/pre>\n<p>By the way, I also included backtrace, just to make sure that the output observed is for the sort cost calculation (as opposed to the tablescan cost calculation).<\/p>\n<p>Subsequently, I compared the return values <span style=\"color:red\">54<\/span> and <span style=\"color:blue\">37<\/span> with the numbers in the optimizer trace. It was easy to establish the following relationship:<\/p>\n<p><a name=\"id1819875642\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 17px;\"><span class=\"ql-right-eqno\"> (2) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-8171fada8711ed617b3853d364a99098_l3.png\" height=\"17\" width=\"258\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#73;&#79;&#92;&#32;&#67;&#111;&#115;&#116;&#32;&#92;&#32;&#112;&#97;&#115;&#115;&#32;&#61;&#32;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#99;&#97;&#108;&#101;&#100;&#92;&#32;&#105;&#111;&#92;&#32;&#99;&#111;&#115;&#116; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>where:<\/p>\n<ul>\n<li><i>scaled io cost<\/i> is returned by the function <i>kkesScaleIO,<\/i><\/li>\n<li><span style=\"color:brown\"><i>IO Cost \/ pass<\/i><\/span> is the value recorded in the optimizer trace.<\/li>\n<\/ul>\n<p>Consequently, the equation <span style=\"color:brown\"><i>Total IO sort cost<\/i><\/span> can be expressed as a function of <i>scaled io cost<\/i> by combining the equations <a href=\"#id348225197\">1<\/a> and <a href=\"#id1819875642\">2<\/a>:<\/p>\n<p><a name=\"id1613009171\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 15px;\"><span class=\"ql-right-eqno\"> (3) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-82e8c923bb09b1666036b6f97e39c6f3_l3.png\" height=\"15\" width=\"436\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#84;&#111;&#116;&#97;&#108;&#92;&#32;&#73;&#79;&#92;&#32;&#115;&#111;&#114;&#116;&#92;&#32;&#99;&#111;&#115;&#116;&#32;&#61;&#32;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#115;&#99;&#97;&#108;&#101;&#100;&#92;&#32;&#105;&#111;&#92;&#32;&#99;&#111;&#115;&#116; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>Further, by stepping through the function and observing the register values I managed to puzzle out how the return value gets calculated:<\/p>\n<p><a name=\"id344296767\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 135px;\"><span class=\"ql-right-eqno\"> (4) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-d9ddaca59b4bede2096a5b41961abb68_l3.png\" height=\"135\" width=\"336\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#115;&#112;&#108;&#105;&#116;&#125; &#92;&#99;&#97;&#110;&#99;&#101;&#108;&#32;&#123;&#32;&#115;&#99;&#97;&#108;&#101;&#100;&#92;&#32;&#105;&#111;&#92;&#32;&#99;&#111;&#115;&#116;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#49;&#125;&#123;&#105;&#111;&#92;&#32;&#115;&#99;&#97;&#108;&#101;&#92;&#32;&#102;&#97;&#99;&#116;&#111;&#114;&#125;&#32;&#43;&#32;&#49;&#32;&#125;&#32;&#92;&#92;&#32;&#92;&#92; &#115;&#99;&#97;&#108;&#101;&#100;&#92;&#32;&#105;&#111;&#92;&#32;&#99;&#111;&#115;&#116;&#32;&#61;&#32;&#92;&#66;&#105;&#103;&#103;&#32;&#92;&#108;&#102;&#108;&#111;&#111;&#114;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#49;&#125;&#123;&#105;&#111;&#92;&#32;&#115;&#99;&#97;&#108;&#101;&#92;&#32;&#102;&#97;&#99;&#116;&#111;&#114;&#125;&#32;&#92;&#66;&#105;&#103;&#103;&#32;&#92;&#114;&#102;&#108;&#111;&#111;&#114;&#32;&#43;&#32;&#49; &#92;&#101;&#110;&#100;&#123;&#115;&#112;&#108;&#105;&#116;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>where <i>io scale factor<\/i> is the return value of the function <i>kkesIOScaleFactor<\/i>.<\/p>\n<p>Both <i>+1<\/i> in the equation <a href=\"#id344296767\">4<\/a> are just the safeguards against the multiplication\/division by zero; boundary conditions, which would lead the whole calculation astray.<\/p>\n<p>Knowing <span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> from the optimizer trace and <i>scaled io cost<\/i> from the gdb trace, I calculated the values for <i>io scale factor<\/i> and concluded following: the lower the block size, the higher the <i>io scale factor<\/i>.<\/p>\n<p>In other words, <i>scaled io cost<\/i> is <span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> \u201csoftened\u201d by dividing it with <i>io scale factor<\/i> which is higher for smaller block sizes. Simply put, it\u2019s this division that prevents an incorrect cost explosion for a large number of smaller blocks.<\/p>\n<p><i>io scale factor<\/i> calculation in <i>kkesIOScaleFactor<\/i> is the last bit to resolve.<\/p>\n<h2>kkesIOScaleFactor<\/h2>\n<p>I observed input and output values for the function. The first argument is passed in the EDI register, the output value is stored in the XMM0 register.<\/p>\n<pre><code>break kkesIOScaleFactor\ncommands 1\np &#36;edi\ncontinue\nend<\/code><\/pre>\n<pre><code>break kkesIOScaleFactor_RETURN_ADDRESS\ncommands 2\np &#36;xmm0\nbacktrace 3\ncontinue\nend<\/code><\/pre>\n<p>Find below the results for <span style=\"color:red\">8k<\/span> and <span style=\"color:blue\">32k<\/span>, respectively:<\/p>\n<pre><code>Thread 2 hit Breakpoint 1, 0x00000000104e4bc0 in kkesIOScaleFactor ()\n&#36;19 = <span style=\"color:red\">8<\/span>\n\nThread 2 hit Breakpoint 2, 0x00000000104e4f7e in kkesIOScaleFactor ()\n&#36;20 = {v4_float = {-3.6487575e-21, 2.21153831, 0, 0}, v2_double = {<span style=\"color:red\">3.6923076923076925<\/span>, 0}, v16_int8 = {-98, -40, -119, -99, -40, -119, \n    13, 64, 0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {-10082, -25207, -30248, 16397, 0, 0, 0, 0}, v4_int32 = {-1651910498, 1074629080, 0, 0}, \n  v2_int64 = {4615496756573624478, 0}, uint128 = 4615496756573624478}\n#0  0x00000000104e4f7e in kkesIOScaleFactor ()\n#1  0x00000000104e5cfc in kkesScaleIO ()\n#2  0x000000000a4e5dbc in kkeSortCosts ()<\/code><\/pre>\n<pre><code>Thread 2 hit Breakpoint 1, 0x00000000104e4bc0 in kkesIOScaleFactor ()\n&#36;5 = <span style=\"color:blue\">2<\/span>\n\nThread 2 hit Breakpoint 2, 0x00000000104e4f7e in kkesIOScaleFactor ()\n&#36;6 = {v4_float = {8.48740821e+32, 1.92307687, 0, 0}, v2_double = {<span style=\"color:blue\">1.3846153846153846<\/span>, 0}, v16_int8 = {118, 98, 39, 118, 98, 39, -10, 63, \n    0, 0, 0, 0, 0, 0, 0, 0}, v8_int16 = {25206, 30247, 10082, 16374, 0, 0, 0, 0}, v4_int32 = {1982292598, 1073096546, 0, 0}, v2_int64 = {\n    4608914572502852214, 0}, uint128 = 4608914572502852214}\n#0  0x00000000104e4f7e in kkesIOScaleFactor ()\n#1  0x00000000104e5cfc in kkesScaleIO ()\n#2  0x000000000a4e5dbc in kkeSortCosts ()<\/code><\/pre>\n<p>The input value, let&#8217;s call it <i>c<\/i>, is <span style=\"color:red\">8<\/span> for <span style=\"color:red\">8k<\/span> and <span style=\"color:blue\">2<\/span> for <span style=\"color:blue\">32k<\/span>. So, I deduced the following formula for <i>c<\/i>:<\/p>\n<p><a name=\"id221100185\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 36px;\"><span class=\"ql-right-eqno\"> (5) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-bfb2c57d47e160bac1e0982573919854_l3.png\" height=\"36\" width=\"134\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#99;&#32;&#61;&#32;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>where <i>block size kb<\/i> is the database block size in kbytes.<\/p>\n<p>Further, by stepping through the function and observing the register values, I deduced the formula for the <i>io scale factor<\/i>.<\/p>\n<p><a name=\"id3169727311\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 49px;\"><span class=\"ql-right-eqno\"> (6) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-8bf4ca512f1be158829a184da2fe134c_l3.png\" height=\"49\" width=\"441\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#105;&#111;&#92;&#32;&#115;&#99;&#97;&#108;&#101;&#92;&#32;&#102;&#97;&#99;&#116;&#111;&#114;&#32;&#61;&#32;&#99;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#32;&#125;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<p>where:<\/p>\n<ul>\n<li>IOSEEKTIM is the system statistic seek time in ms,<\/li>\n<li>IOTFRSPEED KB is the system statistic (IOTFRSPEED) expressed in kbytes.<\/li>\n<\/ul>\n<p>Or after combining the equations <a href=\"#id221100185\">5<\/a> and <a href=\"#id3169727311\">6<\/a>:<\/p>\n<p><a name=\"id507555840\"><\/a><\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 49px;\"><span class=\"ql-right-eqno\"> (7) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-a9a6647e8895ef531c9e2350ded7563d_l3.png\" height=\"49\" width=\"538\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;&#32; &#105;&#111;&#92;&#32;&#115;&#99;&#97;&#108;&#101;&#92;&#32;&#102;&#97;&#99;&#116;&#111;&#114;&#32;&#61;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#32;&#125;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<h1>Total IO sort cost formula<\/h1>\n<p>Finally, <span style=\"color:brown\"><i>Total IO sort cost<\/i><\/span> formula can be derived by combining the equations <a href=\"#id1613009171\">3<\/a>, <a href=\"#id344296767\">4<\/a> and <a href=\"#id507555840\">7<\/a>:<\/p>\n<p class=\"ql-left-displayed-equation\" style=\"line-height: 188px;\"><span class=\"ql-right-eqno\"> (8) <\/span><span class=\"ql-left-eqno\"> &nbsp; <\/span><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/nenadnoveljic.com\/blog\/wp-content\/ql-cache\/quicklatex.com-2d59d8c1dd6502d026876083d0aaf1b0_l3.png\" height=\"188\" width=\"581\" class=\"ql-img-displayed-equation quicklatex-auto-format\" alt=\"&#92;&#98;&#101;&#103;&#105;&#110;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125; &#92;&#98;&#101;&#103;&#105;&#110;&#123;&#115;&#112;&#108;&#105;&#116;&#125; &#84;&#111;&#116;&#97;&#108;&#92;&#32;&#73;&#79;&#92;&#32;&#115;&#111;&#114;&#116;&#92;&#32;&#99;&#111;&#115;&#116;&#32;&#38;&#61;&#32;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#92;&#92;&#32;&#38;&#32;&#92;&#99;&#97;&#110;&#99;&#101;&#108;&#32;&#123;&#43;&#32;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#40;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#49;&#125;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#32;&#125;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#125;&#125;&#32;&#43;&#32;&#49;&#32;&#41;&#125; &#92;&#92;&#32;&#92;&#92;&#32;&#38;&#43;&#32;&#50;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#40;&#32;&#92;&#66;&#105;&#103;&#103;&#32;&#92;&#108;&#102;&#108;&#111;&#111;&#114;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#66;&#108;&#111;&#99;&#107;&#115;&#92;&#32;&#116;&#111;&#92;&#32;&#83;&#111;&#114;&#116;&#32;&#43;&#32;&#49;&#125;&#123;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#32;&#92;&#99;&#100;&#111;&#116;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#98;&#108;&#111;&#99;&#107;&#92;&#32;&#115;&#105;&#122;&#101;&#92;&#32;&#107;&#98;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#32;&#125;&#123;&#32;&#73;&#79;&#83;&#69;&#69;&#75;&#84;&#73;&#77;&#32;&#43;&#32;&#92;&#102;&#114;&#97;&#99;&#123;&#54;&#52;&#125;&#123;&#73;&#79;&#84;&#70;&#82;&#83;&#80;&#69;&#69;&#68;&#92;&#32;&#75;&#66;&#125;&#125;&#125;&#32;&#92;&#66;&#105;&#103;&#103;&#32;&#92;&#114;&#102;&#108;&#111;&#111;&#114;&#32;&#43;&#32;&#49;&#32;&#41; &#92;&#101;&#110;&#100;&#123;&#115;&#112;&#108;&#105;&#116;&#125; &#92;&#101;&#110;&#100;&#123;&#101;&#113;&#117;&#97;&#116;&#105;&#111;&#110;&#42;&#125;\" title=\"Rendered by QuickLaTeX.com\"\/><\/p>\n<h1>Simulator<\/h1>\n<p>Also, I wrote a PL\/SQL anonymous block that simulates the optimizer calculation in order to verify my assumptions in the course of this research. The only input to the simulator is <i>:blocks_to_sort<\/i>, whose value is taken from the optimizer trace. All other parameters are dynamically retrieved.<\/p>\n<p>I enclosed it below for those who&#8217;d like to experiment further:<\/p>\n<pre><code>set serveroutput on size 1000000\n\nvariable blocks_to_sort number\nbegin \n  :blocks_to_sort := 196 ;\n--  :blocks_to_sort := 49 ;\nend;\n\/\n\ndeclare\n  p_blocks_to_sort integer := :blocks_to_sort ;\n  \n  l_ioseektim sys.aux_stats$.pval1%type ;\n  l_iotfrspeed sys.aux_stats$.pval1%type ;\n  l_db_block_size integer ;\n  l_io_scale_factor number ;\n  l_io_cost_per_pass number ;\n  l_total_io_sort_cost number ;\nbegin\n  select pval1 into l_ioseektim from sys.aux_stats$ where pname = 'IOSEEKTIM' ;\n  select pval1 into l_iotfrspeed from sys.aux_stats$ \n    where pname = 'IOTFRSPEED' \n  ;\n  select value into l_db_block_size from v$parameter \n    where name = 'db_block_size' \n  ;\n\n  l_io_scale_factor := \n    ( l_ioseektim + l_db_block_size \/ l_iotfrspeed  ) * \n    ( 65536 \/ l_db_block_size ) \/ ( l_ioseektim + 65536 \/ l_iotfrspeed  ) \n  ;\n  dbms_output.put_line('io scale factor: ' || round(l_io_scale_factor,2) ) ;\n  \n  l_io_cost_per_pass \n    := 2 * ( ( p_blocks_to_sort + 1 ) \/ l_io_scale_factor + 1 )  ;\n  dbms_output.put_line('IO Cost \/ pass: ' || floor(l_io_cost_per_pass ) ) ;\n  \n  l_total_io_sort_cost := p_blocks_to_sort + l_io_cost_per_pass ;\n  dbms_output.put_line(\n    'Total IO sort cost: ' || floor(l_total_io_sort_cost) ) ;\nend ;\n\/<\/code><\/pre>\n<p>The computed values for <span style=\"color:red\">8k<\/span> and <span style=\"color:blue\">32k<\/span>, respectively, perfectly match the numbers from the optimizer trace:<\/p>\n<pre><code>io scale factor: <span style=\"color:red\">3.69<\/span>\n<span style=\"color:brown\">IO Cost \/ pass:<\/span> <span style=\"color:red\">108<\/span>\n<span style=\"color:brown\">Total IO sort cost:<\/span> <span style=\"color:red\">304<\/span><\/code><\/pre>\n<pre><code>io scale factor: <span style=\"color:blue\">1.38<\/span>\n<span style=\"color:brown\">IO Cost \/ pass:<\/span> <span style=\"color:blue\">74<\/span>\n<span style=\"color:brown\">Total IO sort cost:<\/span> <span style=\"color:blue\">123<\/span><\/code><\/pre>\n<h1>Conclusion<\/h1>\n<p>In conclusion, the smaller the database block size, the higher the <span style=\"color:brown\"><i>Total IO sort cost<\/i><\/span>. That&#8217;s a consequence of <span style=\"color:brown\"><i>Blocks to Sort<\/i><\/span> being a main contributor to the cost.<\/p>\n<p>The other summand in the equation is the value proportional to <i>scaled io cost<\/i>, the number of blocks divided by the scaling factor. The scaling factor is higher for a smaller block size, i.e. larger number of blocks. This computation, therefore, prevents a cost explosion for the databases with smaller block size.<\/p>\n<p>The same IO cost calculation is performed in other scenarios too, like table scans. So, the insights gained and the methodology used in this research can be used for generally understanding the IO cost calculations.<\/p>\n<h1>Updates on October 8, 2020<\/h1>\n<h2>io_scale_factor<\/h2>\n<p><i>floor<\/i> on the fraction was missing in the formula for io_scale_factor. This became apparent when I tried to apply it to <a href=\"https:\/\/jonathanlewis.wordpress.com\/2020\/10\/06\/index-ffs-cost-2\/#comments\">Jonathan Lewis&#8217; model for investigating an index FFS cost anomaly<\/a>.<\/p>\n<h2>Interpreting formulas<\/h2>\n<p>I also wrote a <a href=\"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation-2\/\">sequel of this article<\/a> where I interpreted the formulas above.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IO Sort Cost Calculation: formulae and internals <a href=\"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/\" class=\"more-link\">Continue Reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11,24,27,5,32],"tags":[],"class_list":["post-2668","post","type-post","status-publish","format-standard","hentry","category-cost-based-optimizer","category-dtrace","category-gdb","category-oracle","category-sort"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>IO Sort Cost Calculation - All-round Database Topics<\/title>\n<meta name=\"description\" content=\"Unraveling IO Sort Cost Calculation by exploring optimizer internals\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"IO Sort Cost Calculation - All-round Database Topics\" \/>\n<meta property=\"og:description\" content=\"Unraveling IO Sort Cost Calculation by exploring optimizer internals\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/\" \/>\n<meta property=\"og:site_name\" content=\"All-round Database Topics\" \/>\n<meta property=\"article:published_time\" content=\"2019-07-14T16:22:31+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-10-08T14:21:01+00:00\" \/>\n<meta name=\"author\" content=\"Nenad Noveljic\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@NenadNoveljic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nenad Noveljic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/\"},\"author\":{\"name\":\"Nenad Noveljic\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"headline\":\"IO Sort Cost Calculation\",\"datePublished\":\"2019-07-14T16:22:31+00:00\",\"dateModified\":\"2020-10-08T14:21:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/\"},\"wordCount\":1529,\"commentCount\":0,\"articleSection\":[\"cost based optimizer\",\"DTrace\",\"gdb\",\"Oracle\",\"sort\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/\",\"name\":\"IO Sort Cost Calculation - All-round Database Topics\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\"},\"datePublished\":\"2019-07-14T16:22:31+00:00\",\"dateModified\":\"2020-10-08T14:21:01+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\"},\"description\":\"Unraveling IO Sort Cost Calculation by exploring optimizer internals\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/io-sort-cost-calculation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IO Sort Cost Calculation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/\",\"name\":\"All-round Database Topics\",\"description\":\"Nenad Noveljic\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/#\\\/schema\\\/person\\\/51458d9dd86dbbdd19f5add451d44efa\",\"name\":\"Nenad Noveljic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g\",\"caption\":\"Nenad Noveljic\"},\"sameAs\":[\"nenad-noveljic-9b746a6\",\"https:\\\/\\\/x.com\\\/NenadNoveljic\"],\"url\":\"https:\\\/\\\/nenadnoveljic.com\\\/blog\\\/author\\\/nenad\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"IO Sort Cost Calculation - All-round Database Topics","description":"Unraveling IO Sort Cost Calculation by exploring optimizer internals","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:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/","og_locale":"en_US","og_type":"article","og_title":"IO Sort Cost Calculation - All-round Database Topics","og_description":"Unraveling IO Sort Cost Calculation by exploring optimizer internals","og_url":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/","og_site_name":"All-round Database Topics","article_published_time":"2019-07-14T16:22:31+00:00","article_modified_time":"2020-10-08T14:21:01+00:00","author":"Nenad Noveljic","twitter_card":"summary_large_image","twitter_creator":"@NenadNoveljic","twitter_misc":{"Written by":"Nenad Noveljic","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/#article","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/"},"author":{"name":"Nenad Noveljic","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"headline":"IO Sort Cost Calculation","datePublished":"2019-07-14T16:22:31+00:00","dateModified":"2020-10-08T14:21:01+00:00","mainEntityOfPage":{"@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/"},"wordCount":1529,"commentCount":0,"articleSection":["cost based optimizer","DTrace","gdb","Oracle","sort"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/","url":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/","name":"IO Sort Cost Calculation - All-round Database Topics","isPartOf":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#website"},"datePublished":"2019-07-14T16:22:31+00:00","dateModified":"2020-10-08T14:21:01+00:00","author":{"@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa"},"description":"Unraveling IO Sort Cost Calculation by exploring optimizer internals","breadcrumb":{"@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nenadnoveljic.com\/blog\/io-sort-cost-calculation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nenadnoveljic.com\/blog\/"},{"@type":"ListItem","position":2,"name":"IO Sort Cost Calculation"}]},{"@type":"WebSite","@id":"https:\/\/nenadnoveljic.com\/blog\/#website","url":"https:\/\/nenadnoveljic.com\/blog\/","name":"All-round Database Topics","description":"Nenad Noveljic","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nenadnoveljic.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/nenadnoveljic.com\/blog\/#\/schema\/person\/51458d9dd86dbbdd19f5add451d44efa","name":"Nenad Noveljic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a97b796613ea48ec8a7b79c8ffe1c685dcffc920c68121f6238d5caab5070670?s=96&d=mm&r=g","caption":"Nenad Noveljic"},"sameAs":["nenad-noveljic-9b746a6","https:\/\/x.com\/NenadNoveljic"],"url":"https:\/\/nenadnoveljic.com\/blog\/author\/nenad\/"}]}},"_links":{"self":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/comments?post=2668"}],"version-history":[{"count":1,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2668\/revisions"}],"predecessor-version":[{"id":3579,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/posts\/2668\/revisions\/3579"}],"wp:attachment":[{"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/media?parent=2668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/categories?post=2668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nenadnoveljic.com\/blog\/wp-json\/wp\/v2\/tags?post=2668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}