1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Bug#35745: SELECT COUNT(*) is not correct for some partitioned tables.

problem was that ha_partition::records was not implemented, thus
using the default handler::records, which is not correct if the engine
does not support HA_STATS_RECORDS_IS_EXACT.
Solution was to implement ha_partition::records as a wrapper around
the underlying partitions records.

The rows column in explain partitions will now include the total
number of records in the partitioned table.

(recommit after removing out-commented code)
This commit is contained in:
Mattias Jonsson
2008-07-07 22:42:19 +02:00
parent 0a638f6b0d
commit c499df928c
8 changed files with 111 additions and 82 deletions

View File

@@ -134,7 +134,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -153,7 +153,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -169,7 +169,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -197,7 +197,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -212,7 +212,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -227,7 +227,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -242,7 +242,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -257,7 +257,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -272,7 +272,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -391,7 +391,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -410,7 +410,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -429,7 +429,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -455,7 +455,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -473,7 +473,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 23 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -509,7 +509,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -527,7 +527,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -545,7 +545,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1

View File

@@ -148,7 +148,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -175,7 +175,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -207,7 +207,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -249,7 +249,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -276,7 +276,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -301,7 +301,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -324,7 +324,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -345,7 +345,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part1 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -364,7 +364,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) FROM t1 WHERE f_date = '1000-02-10';
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -491,7 +491,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -518,7 +518,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -553,7 +553,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 p6 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -593,7 +593,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 4 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -623,7 +623,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 3 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -651,7 +651,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p4 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -677,7 +677,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 5 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -701,7 +701,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 7 Using where
1 SIMPLE t1 part7 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1
@@ -723,7 +723,7 @@ MYSQLTEST_VARDIR/master-data/test/t1.frm
MYSQLTEST_VARDIR/master-data/test/t1.par
EXPLAIN PARTITIONS SELECT COUNT(*) <> 1 FROM t1 WHERE f_int1 = 3;
id select_type table partitions type possible_keys key key_len ref rows Extra
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 10 Using where
1 SIMPLE t1 p0 ALL NULL NULL NULL NULL 20 Using where
# check read single success: 1
# check read all success: 1
# check read row by row success: 1