[Commits] Rev 3204: Fixed bug mdev-4894. in file:///home/igor/maria/maria-5.1/

Timour Katchaounov timour at montyprogram.com
Wed Aug 14 14:18:20 EEST 2013


Hi Igor,

The patch is approved, however it would be useful if the commit
comment explains exactly what was wrong with the old code.
In general I have hard time understanding the whole acrobatics with
quick keys. The information about range scans is saved and cleared
in several different places, I know that hardly anyone understands
this.

Timour

In the patch, I also have few minor comments:

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2013-05-11 12:55:11 +0000
+++ b/sql/sql_select.cc	2013-08-13 22:21:11 +0000
@@ -6605,19 +6605,18 @@
 	  else
 	  {
 	    sel->needed_reg=tab->needed_reg;

review:
There is no need to remove this right? It is just because below
you set sel->quick_keys anyway to something else?

-	    sel->quick_keys.clear_all();
 	  }
+	  sel->quick_keys= tab->table->quick_keys;
 	  if (!sel->quick_keys.is_subset(tab->checked_keys) ||
               !sel->needed_reg.is_subset(tab->checked_keys))
 	  {
-	    tab->keys=sel->quick_keys;
-            tab->keys.merge(sel->needed_reg);
 	    tab->use_quick= (!sel->needed_reg.is_clear_all() &&
-			     (select->quick_keys.is_clear_all() ||
-			      (select->quick &&
-			       (select->quick->records >= 100L)))) ?
+			     (sel->quick_keys.is_clear_all() ||
+			      (sel->quick &&
+			       (sel->quick->records >= 100L)))) ?

review:
It would be good to add a comment what does '2' and '1' mean.

 	      2 : 1;
 	    sel->read_tables= used_tables & ~current_map;
+            sel->quick_keys.clear_all();
 	  }
 	  if (i != join->const_tables && tab->use_quick != 2)
 	  {					/* Read with cache */


On 08/14/2013 01:21 AM, Igor Babaev wrote:
> At file:///home/igor/maria/maria-5.1/
> 
> ------------------------------------------------------------
> revno: 3204
> revision-id: igor at askmonty.org-20130813222111-vf6dg00gzb0gwipl
> parent: holyfoot at askmonty.org-20130721195506-iwr7ydux2eksbroy
> committer: Igor Babaev <igor at askmonty.org>
> branch nick: maria-5.1
> timestamp: Tue 2013-08-13 15:21:11 -0700
> message:
>   Fixed bug mdev-4894.
>   This a an old legacy performance bug.
>   When a very selective range scan existed for the second table in a join,
>   and, at the same time, there was another range condition depending on the
>   fields of the first table, the optimizer chose a plan with
>   'Range checked for each record'. This plan was extremely inefficient in
>   comparison with the regular selective range scan.
>   As a matter of fact the range scan chosen for each record was the same as
>   that selective range scan. 
>   
>   Changed the test case for bug 24776 to preserve the old output for explain.
>    
> 
> 
> 
> _______________________________________________
> commits mailing list
> commits at mariadb.org
> https://lists.askmonty.org/cgi-bin/mailman/listinfo/commits
> 


More information about the commits mailing list