Below is the list of changes that have just been committed into a local
4.1 repository of psergey. When psergey does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2136 05/03/20 09:46:23 sergefp@stripped +3 -0
Optimizer fix:
* Make range optimizer produce estimate on number of records that will statisfy
table condition, even in the case where quick select is not constructed
* Make join optimizer use this value.
* Change EXPLAIN code to display the number of rows scanned, not the above value
(as this is what docs say about rows column in EXPLAIN output
sql/table.h
1.70 05/03/20 09:46:20 sergefp@stripped +9 -0
Optimizer fix:
* Make range optimizer produce estimate on number of records that will statisfy
table condition, even in the case where quick select is not constructed
* Make join optimizer use this value.
* Change EXPLAIN code to display the number of rows scanned, not the above value
(as this is what docs say about rows column in EXPLAIN output
sql/sql_select.cc
1.389 05/03/20 09:46:20 sergefp@stripped +13 -3
Optimizer fix:
* Make range optimizer produce estimate on number of records that will statisfy
table condition, even in the case where quick select is not constructed
* Make join optimizer use this value.
* Change EXPLAIN code to display the number of rows scanned, not the above value
(as this is what docs say about rows column in EXPLAIN output
sql/opt_range.cc
1.133 05/03/20 09:46:20 sergefp@stripped +4 -0
Make range optimizer produce estimate on number of records that will statisfy
table condition, even in the case where quick select is not constructed
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: sergefp
# Host: newbox.mylan
# Root: /home/psergey/mysql-4.1-look30
--- 1.132/sql/opt_range.cc 2004-11-08 02:13:49 +03:00
+++ 1.133/sql/opt_range.cc 2005-03-20 09:46:20 +03:00
@@ -595,6 +595,8 @@
In the table struct the following information is updated:
quick_keys - Which keys can be used
quick_rows - How many rows the key matches
+ quick_condition_rows - Estimate on number of rows that will
+ satisfy the entire condition.
RETURN VALUES
-1 if impossible select
@@ -725,6 +727,8 @@
needed_reg.set_bit(keynr);
found_records=check_quick_select(¶m, idx, *key);
+ if (found_records != HA_POS_ERROR)
+ head->quick_condition_rows= min(head->quick_condition_rows,
found_records);
if (found_records != HA_POS_ERROR && found_records > 2 &&
head->used_keys.is_set(keynr) &&
(head->file->index_flags(keynr, param.max_key_part, 1) &
--- 1.388/sql/sql_select.cc 2005-03-18 07:09:30 +03:00
+++ 1.389/sql/sql_select.cc 2005-03-20 09:46:20 +03:00
@@ -1696,6 +1696,7 @@
s->needed_reg.init();
table_vector[i]=s->table=table=tables->table;
table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);// record count
+ table->quick_condition_rows= table->file->records;
table->quick_keys.clear_all();
table->reginfo.join_tab=s;
table->reginfo.not_exists_optimize=0;
@@ -2953,6 +2954,7 @@
{
/* Estimate cost of reading table. */
tmp= s->table->file->scan_time();
+ rnd_records= s->table->quick_condition_rows;
if (s->on_expr) // Can't use join cache
{
/*
@@ -5804,6 +5806,7 @@
join->thd->row_count= 0;
do
{
+ //printf("%s read_record FIRST\n", join_tab->table->path);
if (join->thd->killed) // Aborted by user
{
my_error(ER_SERVER_SHUTDOWN,MYF(0)); /* purecov: inspected */
@@ -9496,9 +9499,16 @@
item_list.push_back(item_null);
}
/* rows */
- item_list.push_back(new Item_int((longlong) (ulonglong)
- join->best_positions[i]. records_read,
- 21));
+ ha_rows examined_rows;
+ if (tab->select && tab->select->quick)
+ examined_rows= tab->select->quick->records;
+ else if (tab->type == JT_NEXT || tab->type == JT_ALL)
+ examined_rows= tab->table->file->records;
+ else
+ examined_rows=(ha_rows)join->best_positions[i]. records_read;
+
+ item_list.push_back(new Item_int((longlong) (ulonglong) examined_rows,
+ 21));
/* extra */
my_bool key_read=table->key_read;
if ((tab->type == JT_NEXT || tab->type == JT_CONST) &&
--- 1.69/sql/table.h 2004-12-11 15:54:07 +03:00
+++ 1.70/sql/table.h 2005-03-20 09:46:20 +03:00
@@ -183,6 +183,15 @@
ha_rows quick_rows[MAX_KEY];
uint quick_key_parts[MAX_KEY];
key_part_map const_key_parts[MAX_KEY];
+ /*
+ Estimate of number of records that satisfy SARGable part of the table
+ ondition, or table->file->records if no SARGable condition could be
+ constructed.
+ This value is used (by join optimizer) as an estimate of number of
+ records that will pass the table condition (condition on this table
+ fields and constants).
+ */
+ ha_rows quick_condition_rows;
ulong query_id;
uchar frm_version;
| Thread |
|---|
| • bk commit into 4.1 tree (sergefp:1.2136) | Sergey Petrunia | 20 Mar |