diff options
author | Sergey Vojtovich <svoj@mysql.com> | 2009-02-05 17:03:47 +0400 |
---|---|---|
committer | Sergey Vojtovich <svoj@mysql.com> | 2009-02-05 17:03:47 +0400 |
commit | 071cfc03b7fb706b9262b58a794c6a8871592c3e (patch) | |
tree | 81da4e17ea29c46dd3810eafc956418a5c090208 /mysql-test/t/merge.test | |
parent | b9d02d4669ad45444f5082979e37908125eea3de (diff) | |
download | mariadb-git-071cfc03b7fb706b9262b58a794c6a8871592c3e.tar.gz |
BUG#39185 - Cardinality for merge tables calculated incorrectly.
Every subsequent query to a merge table with indexes was lowering
down cardinality.
The problem was that key statistics was not cleared when merge
children were detached. Causing next attach children perform
incremental key statistics calculation.
Fixed by clearing key statistics when attaching first child.
mysql-test/r/merge.result:
A test case for BUG#39185.
mysql-test/t/merge.test:
A test case for BUG#39185.
storage/myisammrg/myrg_open.c:
Clear key statistics when we're attaching first child, even
if it's buffer was allocated before. This is needed because
detach_children() doesn't clear statistics, causing incremental
statistics calculation.
Diffstat (limited to 'mysql-test/t/merge.test')
-rw-r--r-- | mysql-test/t/merge.test | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 118f8771f91..e8c514f3804 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -1435,4 +1435,17 @@ EXPLAIN SELECT COUNT(*) FROM t1; EXPLAIN SELECT COUNT(*) FROM t4; DROP TABLE t1, t2, t3, t4; +# +# BUG#39185 - Cardinality for merge tables calculated incorrectly. +# +CREATE TABLE t1(a INT, KEY(a)); +INSERT INTO t1 VALUES(0),(1),(2),(3),(4); +ANALYZE TABLE t1; +CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; +DROP TABLE t1, m1; + --echo End of 5.1 tests |