|
| 1 | +# verify that index scans on parititions are not slow |
| 2 | +# due totokudb bulk fetch not being used |
| 3 | +source include/have_tokudb.inc; |
| 4 | +set default_storage_engine='tokudb'; |
| 5 | +disable_warnings; |
| 6 | +drop table if exists t,t1,t2,t3; |
| 7 | + |
| 8 | +CREATE TABLE `t` ( |
| 9 | + `num` int(10) unsigned auto_increment NOT NULL, |
| 10 | + `val` varchar(32) DEFAULT NULL, |
| 11 | + PRIMARY KEY (`num`) |
| 12 | +); |
| 13 | + |
| 14 | +# put 8M rows into t |
| 15 | +INSERT INTO t values (null,null); |
| 16 | +INSERT INTO t SELECT null,null FROM t; |
| 17 | +INSERT INTO t SELECT null,null FROM t; |
| 18 | +INSERT INTO t SELECT null,null FROM t; |
| 19 | +INSERT INTO t SELECT null,null FROM t; |
| 20 | +INSERT INTO t SELECT null,null FROM t; |
| 21 | +INSERT INTO t SELECT null,null FROM t; |
| 22 | +INSERT INTO t SELECT null,null FROM t; |
| 23 | +INSERT INTO t SELECT null,null FROM t; |
| 24 | +INSERT INTO t SELECT null,null FROM t; |
| 25 | +INSERT INTO t SELECT null,null FROM t; |
| 26 | +INSERT INTO t SELECT null,null FROM t; |
| 27 | +INSERT INTO t SELECT null,null FROM t; |
| 28 | +INSERT INTO t SELECT null,null FROM t; |
| 29 | +INSERT INTO t SELECT null,null FROM t; |
| 30 | +INSERT INTO t SELECT null,null FROM t; |
| 31 | +INSERT INTO t SELECT null,null FROM t; |
| 32 | +INSERT INTO t SELECT null,null FROM t; |
| 33 | +INSERT INTO t SELECT null,null FROM t; |
| 34 | +INSERT INTO t SELECT null,null FROM t; |
| 35 | +INSERT INTO t SELECT null,null FROM t; |
| 36 | +INSERT INTO t SELECT null,null FROM t; |
| 37 | +INSERT INTO t SELECT null,null FROM t; |
| 38 | +INSERT INTO t SELECT null,null FROM t; |
| 39 | +SELECT count(*) FROM t; |
| 40 | + |
| 41 | +CREATE TABLE `t1` ( |
| 42 | + `num` int(10) unsigned NOT NULL, |
| 43 | + `val` varchar(32) DEFAULT NULL, |
| 44 | + PRIMARY KEY (`num`) |
| 45 | +); |
| 46 | + |
| 47 | +CREATE TABLE `t2` ( |
| 48 | + `num` int(10) unsigned NOT NULL, |
| 49 | + `val` varchar(32) DEFAULT NULL, |
| 50 | + PRIMARY KEY (`num`) |
| 51 | +) |
| 52 | +PARTITION BY HASH (num) PARTITIONS 10; |
| 53 | + |
| 54 | +CREATE TABLE `t3` ( |
| 55 | + `num` int(10) unsigned NOT NULL, |
| 56 | + `val` varchar(32) DEFAULT NULL, |
| 57 | + PRIMARY KEY (`num`) |
| 58 | +) |
| 59 | +PARTITION BY RANGE (num) |
| 60 | +(PARTITION p0 VALUES LESS THAN (1000000), |
| 61 | + PARTITION p1 VALUES LESS THAN (2000000), |
| 62 | + PARTITION p2 VALUES LESS THAN (3000000), |
| 63 | + PARTITION p3 VALUES LESS THAN (4000000), |
| 64 | + PARTITION p4 VALUES LESS THAN (5000000), |
| 65 | + PARTITION p5 VALUES LESS THAN (6000000), |
| 66 | + PARTITION p6 VALUES LESS THAN (7000000), |
| 67 | + PARTITION p7 VALUES LESS THAN (8000000), |
| 68 | + PARTITION px VALUES LESS THAN MAXVALUE); |
| 69 | + |
| 70 | +insert into t1 select * from t; |
| 71 | +insert into t2 select * from t; |
| 72 | +insert into t3 select * from t; |
| 73 | + |
| 74 | +# verify that full index scans on partitioned tables t2 and t3 are comparable to a non-partitioned table t1 |
| 75 | +let $s = `select to_seconds(now())`; |
| 76 | +select count(*) from t1; |
| 77 | +let $t1 = `select to_seconds(now()) - $s`; |
| 78 | +# echo $t1; |
| 79 | + |
| 80 | +let $s = `select to_seconds(now())`; |
| 81 | +select count(*) from t2; |
| 82 | +let $t2 = `select to_seconds(now()) - $s`; |
| 83 | +# echo $t2; |
| 84 | +let $d = `select abs($t2 - $t1) <= $t1`; |
| 85 | +echo $d; |
| 86 | + |
| 87 | +let $s = `select to_seconds(now())`; |
| 88 | +select count(*) from t3; |
| 89 | +let $t3 = `select to_seconds(now()) - $s`; |
| 90 | +# echo $t3; |
| 91 | +let $d = `select abs($t3 - $t1) <= $t1`; |
| 92 | +echo $d; |
| 93 | + |
| 94 | +let $s = `select to_seconds(now())`; |
| 95 | +select count(*) from t1 where num>7000000; |
| 96 | +let $t1 = `select to_seconds(now()) - $s`; |
| 97 | +# echo $t1; |
| 98 | + |
| 99 | +let $s = `select to_seconds(now())`; |
| 100 | +select count(*) from t2 where num>7000000; |
| 101 | +let $t2 = `select to_seconds(now()) - $s`; |
| 102 | +# echo $t2; |
| 103 | +let $d = `select abs($t2 - $t1) <= $t1`; |
| 104 | +echo $d; |
| 105 | + |
| 106 | +let $s = `select to_seconds(now())`; |
| 107 | +select count(*) from t3 where num>7000000; |
| 108 | +let $t3 = `select to_seconds(now()) - $s`; |
| 109 | +# echo $t3; |
| 110 | +let $d = `select abs($t3 - $t1) <= $t1`; |
| 111 | +echo $d; |
| 112 | + |
| 113 | +enable_warnings; |
| 114 | +drop table if exists t,t1,t2,t3; |
0 commit comments