Commit 07b8aefe authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-9504: ANALYZE TABLE shows wrong 'rows' value for ORDER BY query

Revert the patch for MDEV-9504.
It causes test failures, attempt to fix these causes more failures. The
source of all this is that the code in test_if_skip_sort_order() has
a peculiar way of treating select_limit parameter:
Correct value is computed when the query plan is changed. In other cases,
we use an approximation that ignores the presence of GROUP BY clause,
or JOINs, or both.

A patch that fixes all of the above would be too big to do in 10.1
parent 55ea2654
...@@ -583,28 +583,4 @@ ANALYZE ...@@ -583,28 +583,4 @@ ANALYZE
} }
} }
drop table t2; drop table t2;
drop table t1; drop table t0,t1;
#
# MDEV-9504: ANALYZE TABLE shows wrong 'rows' value for ORDER BY query
#
create table t1 (
a int,
filler1 char(128),
filler2 char(128),
key(a)
);
insert into t1
select A.a+10*B.a+100*C.a, repeat('abc-',32), repeat('abc-',32)
from t0 A, t0 B, t0 C;
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status Table is already up to date
explain select a from t1 order by a limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL a 5 NULL 10 Using index
# 'rows' in ANALYZE output must match 'rows' in EXPLAIN:
analyze select a from t1 order by a limit 10;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1 index NULL a 5 NULL 10 10.00 100.00 100.00 Using index
drop table t1;
drop table t0;
...@@ -174,27 +174,4 @@ select col1 f1, col2 f2, col1 f3 from t2 group by f1; ...@@ -174,27 +174,4 @@ select col1 f1, col2 f2, col1 f3 from t2 group by f1;
drop table t2; drop table t2;
drop table t1; drop table t0,t1;
--echo #
--echo # MDEV-9504: ANALYZE TABLE shows wrong 'rows' value for ORDER BY query
--echo #
create table t1 (
a int,
filler1 char(128),
filler2 char(128),
key(a)
);
insert into t1
select A.a+10*B.a+100*C.a, repeat('abc-',32), repeat('abc-',32)
from t0 A, t0 B, t0 C;
analyze table t1;
explain select a from t1 order by a limit 10;
--echo # 'rows' in ANALYZE output must match 'rows' in EXPLAIN:
analyze select a from t1 order by a limit 10;
drop table t1;
drop table t0;
...@@ -21031,14 +21031,12 @@ check_reverse_order: ...@@ -21031,14 +21031,12 @@ check_reverse_order:
} }
table->file->ha_index_or_rnd_end(); table->file->ha_index_or_rnd_end();
if (select_limit < table->stat_records())
tab->limit= select_limit;
if (tab->join->select_options & SELECT_DESCRIBE) if (tab->join->select_options & SELECT_DESCRIBE)
{ {
tab->ref.key= -1; tab->ref.key= -1;
tab->ref.key_parts= 0; tab->ref.key_parts= 0;
if (select_limit < table->stat_records())
tab->limit= select_limit;
table->disable_keyread(); table->disable_keyread();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment