summaryrefslogtreecommitdiff
path: root/mysql-test/t/partition_pruning.test
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2010-08-26 17:14:18 +0200
committerMattias Jonsson <mattias.jonsson@oracle.com>2010-08-26 17:14:18 +0200
commite5bab33a2a4a97261b70ac7c5ef4f4f694896109 (patch)
tree67ed61bbde7ee3f7dd2ffb26e778277d793df31b /mysql-test/t/partition_pruning.test
parentbc05efd8aa116e9609941ad1f19665b79eca0eef (diff)
downloadmariadb-git-e5bab33a2a4a97261b70ac7c5ef4f4f694896109.tar.gz
Bug#53806: Wrong estimates for range query in partitioned MyISAM table
Bug#46754: 'rows' field doesn't reflect partition pruning The EXPLAIN's result in 'rows' field was evaluated to number of rows when the table was opened (not from the table cache) and only the partitions left after pruning was updated with its correct number of rows. The evaluation of the 'rows' field was using handler::records() which is a potentially expensive call, and ignores the partitioning pruning. The fix was to use the handlers stats.records after updating it with ::info(HA_STATUS_VARIABLE) instead. mysql-test/r/partition_pruning.result: updated result mysql-test/t/partition_pruning.test: Added test. sql/sql_select.cc: Use ::info + stats.records instead of ::records().
Diffstat (limited to 'mysql-test/t/partition_pruning.test')
-rw-r--r--mysql-test/t/partition_pruning.test24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/partition_pruning.test b/mysql-test/t/partition_pruning.test
index 358832496e5..db544d4643f 100644
--- a/mysql-test/t/partition_pruning.test
+++ b/mysql-test/t/partition_pruning.test
@@ -9,6 +9,30 @@ drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
--enable_warnings
--echo #
+--echo # Bug#53806: Wrong estimates for range query in partitioned MyISAM table
+--echo # Bug#46754: 'rows' field doesn't reflect partition pruning
+--echo #
+CREATE TABLE t1 (a INT PRIMARY KEY)
+PARTITION BY RANGE (a) (
+PARTITION p0 VALUES LESS THAN (1),
+PARTITION p1 VALUES LESS THAN (2),
+PARTITION p2 VALUES LESS THAN (3),
+PARTITION p3 VALUES LESS THAN (4),
+PARTITION p4 VALUES LESS THAN (5),
+PARTITION p5 VALUES LESS THAN (6),
+PARTITION max VALUES LESS THAN MAXVALUE);
+
+INSERT INTO t1 VALUES (-1),(0),(1),(2),(3),(4),(5),(6),(7),(8);
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a < 7;
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 9 # 11 #
+EXPLAIN PARTITIONS SELECT * FROM t1 WHERE a <= 1;
+DROP TABLE t1;
+
+--echo #
--echo # Bug#49742: Partition Pruning not working correctly for RANGE
--echo #
CREATE TABLE t1 (a INT PRIMARY KEY)