List:Commits« Previous MessageNext Message »
From:Olav Sandstaa Date:May 29 2012 10:24am
Subject:bzr push into mysql-trunk branch (olav.sandstaa:3905 to 3906) WL#6082
View as plain text  
 3906 Olav Sandstaa	2012-05-29
      WL#6082 Improve the Disk-Sweep Multi-Range Read cost model
      Patch 2: Fix bug in how IO and CPU cost are computed for multi-pass scans. 
      When computing the cost for each scan, the record estimate for the
      total number of records is used. This causes the IO cost and CPU cost
      to become too high. Change this to use the number of records that
      will be read per scan.
     @ sql/
        WL#6082: Use correct record estimate when computing CPU and IO cost
        for a scan.

 3905 Olav Sandstaa	2012-05-29
      WL#6082 Improve the Disk-Sweep Multi-Range Read cost model
      Patch 1: Improve estimation of required size of sort buffer.
      Fixes the following two issues with how the estimated size of
      needed sort buffer for a single scan DS-MRR is calculated:
      a. An early version of the DS-MRR implementation used the sort buffer
         to store the current position of the scan each time it had filled
         the sort buffer. This was needed in order to be able to restart the
         scan next time it should fill the sort buffer. This implementation
         has since been changed to use a second handler object for scanning
         the index. Thus the there is no longer a need for storing the
         current position in the sort buffer. This patch removes the code
         that included space for this in estimation of the buffer size.
      b. When a single scan is needed, in most cases the buffer size
         supplied by the optimizer code is too high. To reduce the amount of
         buffer space allocated we should adjust this to what is needed. The
         current code does not adjust the estimated buffer size
         correctly. It will never reduce it, only increase it (which is the
         opposite of the intention). The new code estimates the buffer size
         a. Estimate of number of keys to sort: Add 20% to the estimated
            number of records. If this estimate is less than 100 keys, then
            adjust it to use 100 keys as the estimate.
         b. Adjusting the sort buffer size: If the estimated buffer space
            is lower than the size of the sort buffer provided by the
            optimizer code, then adjust the buffer space size down to the
            estimated size.
     @ sql/
        WL#6082: Fix how DsMrr_impl::get_disk_sweep_mrr_cost() adjust the 
        buffer size when there is a single scan needed.

=== modified file 'sql/'

=== modified file 'sql/'
--- a/sql/	2012-05-29 09:31:04 +0000
+++ b/sql/	2012-05-29 10:17:05 +0000
@@ -6256,14 +6256,13 @@
                                          uint *buffer_size, 
                                          Cost_estimate *cost)
-  ulong max_buff_entries;
   ha_rows rows_in_last_step;
   uint n_full_steps;
   double index_read_cost;
   const uint elem_size= h->ref_length + 
                         sizeof(void*) * (!test(flags & HA_MRR_NO_ASSOCIATION));
-  max_buff_entries = *buffer_size / elem_size;
+  const ha_rows max_buff_entries= *buffer_size / elem_size;
   if (!max_buff_entries)
     return TRUE; /* Buffer has not enough space for even 1 rowid */
@@ -6281,7 +6280,7 @@
   if (n_full_steps)
-    get_sort_and_sweep_cost(table, rows, cost);
+    get_sort_and_sweep_cost(table, max_buff_entries, cost);

No bundle (reason: useless for push emails).
bzr push into mysql-trunk branch (olav.sandstaa:3905 to 3906) WL#6082Olav Sandstaa29 May