[Commits] Rev 4144: MDEV-5992: EITS: Selectivity of non-indexed condition is counted twice in table's fanout in file:///home/psergey/dev2/10.0/

Sergey Petrunya psergey at askmonty.org
Mon Mar 31 22:24:14 EEST 2014


At file:///home/psergey/dev2/10.0/

------------------------------------------------------------
revno: 4144
revision-id: psergey at askmonty.org-20140331192414-rgxrva863va8afsa
parent: psergey at askmonty.org-20140331155148-174h1ee2c4vbjbq5
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 10.0
timestamp: Mon 2014-03-31 14:24:14 -0500
message:
  MDEV-5992: EITS: Selectivity of non-indexed condition is counted twice in table's fanout
  - When using quick select, selectivity for COND(table) is accounted for 
    in matching_candidates_in_table().
    Dont let table_cond_selectivity() apply it for the second time
    (no testcase as the problem is only visible in debugger for simple testcases)
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2014-03-31 15:51:48 +0000
+++ b/sql/sql_select.cc	2014-03-31 19:24:14 +0000
@@ -7279,33 +7279,18 @@ double table_cond_selectivity(JOIN *join
   TABLE *table= s->table;
   MY_BITMAP *read_set= table->read_set;
   double sel= s->table->cond_selectivity;
-  double table_records= table->stat_records();
   POSITION *pos= &join->positions[idx];
   uint keyparts= 0;
   uint found_part_ref_or_null= 0;
 
-  /* Discount the selectivity of the access method used to join table s */
-  if (s->quick && s->quick->index != MAX_KEY)
-  {
-    if (pos->key == 0 && table_records > 0)
-    {
-      /*
-        We're using a quick select. the part of WHERE that was used to
-        construct the quick select will not be selective (all rows we read 
-        will match). Remove selectivity factor of this quick select from join's
-        selectivity.
-      */
-      sel/= table->quick_rows[s->quick->index]/table_records;
-    }
-  }
-  else if (pos->key != 0)
+  if (pos->key != 0)
   {
     /* 
       A ref/ access or hash join is used to join table
 
       It could have some parts with "t.key=const". Ref access guarantees that
       we will only get records where the condition holds, so we should remove
-      its its selectivity from the condition selectivity.
+      its selectivity from the condition selectivity.
       
       (TODO: more details about the "t.key=othertable.col" case)
     */
@@ -7356,8 +7341,8 @@ double table_cond_selectivity(JOIN *join
   else
   {
     /*
-      We get here when the table uses full table scan.
-      Selectivity of COND(table) is already accounted for in
+      We get here when the table uses full table scan, or quick select.
+      Selectivity of COND(table) is already accounted for in 
       matching_candidates_in_table().
     */
     sel= 1;



More information about the commits mailing list