From: Ole John Aske Date: January 31 2011 3:10pm Subject: bzr commit into mysql-trunk branch (ole.john.aske:3551) Bug#59326 List-Archive: http://lists.mysql.com/commits/130055 X-Bug: 59326 Message-Id: <20110131151100.A9155223@fimafeng09.norway.sun.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5631669408045228934==" --===============5631669408045228934== MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline #At file:///net/fimafeng09/export/home/tmp/oleja/mysql/mysql-trunk/ based on revid:ole.john.aske@stripped 3551 Ole John Aske 2011-01-31 Refactoring cleanup related to bug#59326 and my previous set of fixes for this bug: - Added 'TIME_FOR_COMPARE' to current_read_time where it is initially calculated - Removed later adding of TIME_FOR_COMPARE whenever it is used. - Used local variable '*position' instead of 'join->positions + idx' a few places. - Replaced a few references to 'restore_prev_nj_state()' with 'backout_nj_sj_state()' in comments (Has been renamed) This fix contains no (intentional) changes of logic. modified: sql/sql_select.cc === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2011-01-31 14:42:02 +0000 +++ b/sql/sql_select.cc 2011-01-31 15:10:55 +0000 @@ -8209,12 +8209,13 @@ best_extension_by_limited_search(JOIN /* Find the best access method from 's' to the current partial plan */ POSITION loose_scan_pos; best_access_path(join, s, remaining_tables, idx, FALSE, record_count, - join->positions + idx, &loose_scan_pos); + position, &loose_scan_pos); /* Compute the cost of extending the plan with 's' */ - current_record_count= record_count * position->records_read; - current_read_time= read_time + position->read_time; + current_read_time= read_time + + position->read_time + + current_record_count / (double) TIME_FOR_COMPARE; if (has_sj) { @@ -8232,15 +8233,12 @@ best_extension_by_limited_search(JOIN join->positions[idx].sj_strategy= SJ_OPT_NONE; /* Expand only partial plans with lower cost than the best QEP so far */ - if ((current_read_time + - current_record_count / (double) TIME_FOR_COMPARE) >= join->best_read) + if (current_read_time >= join->best_read) { DBUG_EXECUTE("opt", print_plan(join, idx+1, current_record_count, read_time, - (current_read_time + - current_record_count / - (double) TIME_FOR_COMPARE), + current_read_time, "prune_by_cost");); backout_nj_sj_state(remaining_tables, s); continue; @@ -8251,10 +8249,7 @@ best_extension_by_limited_search(JOIN the optimal QEPs, thus it results in a non-exhaustive search. */ if (prune_level == 1) - { - // Compare cost is also part of 'current cost' - current_read_time+= current_record_count / (double) TIME_FOR_COMPARE; - + { if (best_record_count > current_record_count || best_read_time > current_read_time || (idx == join->const_tables && // 's' is the first table in the QEP @@ -8280,13 +8275,11 @@ best_extension_by_limited_search(JOIN backout_nj_sj_state(remaining_tables, s); continue; } - // Compensate above '+=' in order to keep remaining logic unchanged: - current_read_time-= current_record_count / (double) TIME_FOR_COMPARE; } if ( (search_depth > 1) && (remaining_tables & ~real_table_bit) & allowed_tables ) - { /* Recursively expand the current partial plan */ - current_read_time+= current_record_count / (double) TIME_FOR_COMPARE; + { + /* Explore more best extensions of plan */ if (best_extension_by_limited_search(join, remaining_tables & ~real_table_bit, idx + 1, @@ -8301,7 +8294,6 @@ best_extension_by_limited_search(JOIN 'join' is either the best partial QEP with 'search_depth' relations, or the best complete QEP so far, whichever is smaller. */ - current_read_time+= current_record_count / (double) TIME_FOR_COMPARE; if (join->sort_by_table && join->sort_by_table != join->positions[join->const_tables].table->table) @@ -14334,7 +14326,7 @@ void advance_sj_state(JOIN *join, table_ proceeds up the tree to NJ1, incrementing its counter as well. All join nests are now completely covered by the QEP. - restore_prev_nj_state() does the above in reverse. As seen above, the node + backout_nj_sj_state() does the above in reverse. As seen above, the node NJ1 contains the nodes t2, t3, and NJ2. Its counter being equal to 3 means that the plan covers t2, t3, and NJ2, @e and that the sub-plan (t4 x t5) completely covers NJ2. The removal of t5 from the partial plan will first @@ -14345,7 +14337,7 @@ void advance_sj_state(JOIN *join, table_ NJ2. SYNOPSIS - restore_prev_nj_state() + backout_nj_sj_state() last join table to remove, it is assumed to be the last in current partial join order. --===============5631669408045228934== MIME-Version: 1.0 Content-Type: text/bzr-bundle; charset="us-ascii"; name="bzr/ole.john.aske@stripped" Content-Transfer-Encoding: 7bit Content-Disposition: inline # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: ole.john.aske@stripped\ # v08nf8m8ft1ebfxu # target_branch: file:///net/fimafeng09/export/home/tmp/oleja/mysql\ # /mysql-trunk/ # testament_sha1: 3b343269f54ad4def8c00daf536a45964fa6d5a7 # timestamp: 2011-01-31 16:11:00 +0100 # source_branch: file:///net/fimafeng09/export/home/tmp/oleja/mysql\ # /mysql-5.5/ # base_revision_id: ole.john.aske@stripped\ # x5pw1ivy3iqr5d0l # # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWc+ETY4AAk5/gFQQCEBZ//// e3LWAL////hQBW67s90uuzee969q4m73dV7wlChoU2qeyYVP9TU2knmpP1NGpmk0xonqZHqB6g0D IiaZNMTSaU02pm1PUh6j1AZA0PUAA00CUEEaRNqejUwKPUPTUehpNPUDQNAAPUDFT0KJ6TZTah6j TCHoTQDRkyGTQBtTQCSSZNTBqm1PQSPU9J5JoyPT0p6nqGAT1DRk00OAz0mO3TtgbQNZifv4bVv5 eTQuhf8s4tVzMPRiWiSFESA21QgFRfVVoOfXffg59YkZ5JGIBfhQG0iGCIr3bvKV/BrYKPvFH+sP m9QVUB28Cx0Uty2vhuVZIXK0c5OMyS6VJSbSrrZNhlLzr2Yt8IGjWzXwl+uSOWOZuN32h2O6bNn3 F12afm9+G61ywFK7rRF66QZi2DQ93Y++TOvIOJBReaVsVDfvyopz9Orm0dOq1GVC2U5M5ZjhQxgq FPgvRDTClWuOzvZY8S9UKlh/BDE5OgW/ZpycpH1CbApinuixJFSekSZI1W7GnlDPwkADS52s5pDy 0QyQwOMLq7HEXiIpcUCCY6UdwsAZUitym6R6ZCDigWUo92GAimwRC+M5gKcGGq6YRKOtODuJw3y+ uLxTu3htt7bSdVSjTwixuIbAruaOCh7WhUI4AgiDk4iuTXQipkex5WqDmYzXtsaww10wlBDxV1wS 1ECp2hk+AbFBjCF20DVK2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