Commit 81f6ecc4 authored by Rich Prohaska's avatar Rich Prohaska

DB-724 speed up and simplify the bulk fetch tests

parent 0ea9d023
...@@ -98,6 +98,36 @@ count(*) ...@@ -98,6 +98,36 @@ count(*)
SELECT count(*) from t; SELECT count(*) from t;
count(*) count(*)
1048576 1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
set tokudb_bulk_fetch=OFF; set tokudb_bulk_fetch=OFF;
SELECT count(*) from t; SELECT count(*) from t;
count(*) count(*)
...@@ -159,6 +189,36 @@ count(*) ...@@ -159,6 +189,36 @@ count(*)
SELECT count(*) from t; SELECT count(*) from t;
count(*) count(*)
1048576 1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
SELECT count(*) from t;
count(*)
1048576
1 1
set tokudb_bulk_fetch=ON; set tokudb_bulk_fetch=ON;
SELECT count(*) from t where num > 700000; SELECT count(*) from t where num > 700000;
...@@ -221,6 +281,36 @@ count(*) ...@@ -221,6 +281,36 @@ count(*)
SELECT count(*) from t where num > 700000; SELECT count(*) from t where num > 700000;
count(*) count(*)
348576 348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
set tokudb_bulk_fetch=OFF; set tokudb_bulk_fetch=OFF;
SELECT count(*) from t where num > 700000; SELECT count(*) from t where num > 700000;
count(*) count(*)
...@@ -282,5 +372,35 @@ count(*) ...@@ -282,5 +372,35 @@ count(*)
SELECT count(*) from t where num > 700000; SELECT count(*) from t where num > 700000;
count(*) count(*)
348576 348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
SELECT count(*) from t where num > 700000;
count(*)
348576
1 1
drop table t; drop table t;
...@@ -6,64 +6,56 @@ source include/have_tokudb.inc; ...@@ -6,64 +6,56 @@ source include/have_tokudb.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` ( CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
); );
# put 8M rows into t # put 1M rows into t1
INSERT INTO t values (null,null); INSERT INTO t1 values (null,null);
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; SELECT count(*) FROM t1;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create first table from source table t
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
let $s = `select to_seconds(now())`; let $maxq = 10;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1; CREATE TABLE t2 AS SELECT count(*) from t1;
...@@ -71,48 +63,41 @@ while ($i < $maxq) { ...@@ -71,48 +63,41 @@ while ($i < $maxq) {
inc $i; inc $i;
} }
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par # Check that the time with bulk fetch off is at least twice that whith bulk fetch on
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_on $time_elapsed_off; }
if (!$verdict) { echo index $time_elapsed_on $time_elapsed_off; }
let $maxrq = 30; let $maxq = 30;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
SELECT count(*) from t1 where num > 7000000; CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 7000000; CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par # Check that the time with bulk fetch off is at least twice that whith bulk fetch on
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_on $time_elapsed_off; }
if (!$verdict) { echo range $time_elapsed_on $time_elapsed_off; }
drop table t,t1; drop table t1;
...@@ -7,137 +7,96 @@ source include/have_partition.inc; ...@@ -7,137 +7,96 @@ source include/have_partition.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2,t3; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` (
`num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
);
# put 8M rows into t
INSERT INTO t values (null,null);
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create base table (control table) from source table t
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
# Create source hash partitioned table from source table t # Create source hash partitioned table from source table t
CREATE TABLE `t2` ( CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
) PARTITION BY HASH (num) ) PARTITION BY HASH (num) PARTITIONS 8;
PARTITIONS 8 as select * from t;
# put 1M rows into t1
let $s = `select to_seconds(now())`; INSERT INTO t1 values (null,null);
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
SELECT count(*) FROM t1;
let $maxq = 20;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint); CREATE TABLE t2 AS SELECT count(*) from t1;
SELECT count(*) from t1; DROP TABLE t2;
DROP TABLE t3;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TABLE t3 AS SELECT count(*) from t2; CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t3; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; # check that bulk fetch on is at least 2 times faster than bulk fetch off
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
# Additionally, it is important to note that 1.5 is the multiplier applied to the time_elapsed_select
# value because it appears that MySQL 5.5.39 uses a sorted index scan during the create select statement
# while Percona Server 5.6 uses an unsorted index scan.
# The issue has been resolved in MySQL 5.6 but still persists in Maria 10.0.12
# in the defect found at https://mariadb.atlassian.net/browse/MDEV-6547.
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= 1.5 * $time_elapsed_select`;
echo $verdict; echo $verdict;
if (!$verdict) { echo index scan t2 $time_elapsed_create_select $time_elapsed_select; } if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; }
let $maxrq = 30; let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint); CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
SELECT count(*) from t1 where num > 7000000; DROP TABLE t2;
DROP TABLE t3;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TABLE t3 AS SELECT count(*) from t2 where num > 7000000; CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t3; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; # check that bulk fetch on is at least 2 times faster than bulk fetch off
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
# Additionally, it is important to note that 1.5 is the multiplier applied to the time_elapsed_select
# value because it appears that MySQL 5.5.39 uses a sorted index scan during the create select statement
# while Percona Server 5.6 uses an unsorted index scan.
# The issue has been resolved in MySQL 5.6 but still persists in Maria 10.0.12
# in the defect found at https://mariadb.atlassian.net/browse/MDEV-6547.
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= 1.5 * $time_elapsed_select`;
echo $verdict; echo $verdict;
if (!$verdict) { echo range scan t2 $time_elapsed_create_select $time_elapsed_select; } if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
drop table t,t1,t2; drop table t1;
...@@ -7,132 +7,103 @@ source include/have_partition.inc; ...@@ -7,132 +7,103 @@ source include/have_partition.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` (
`num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
);
# put 8M rows into t
INSERT INTO t values (null,null);
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create base table (control table) from source table t
CREATE TABLE `t1` ( CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
# Create source range partitioned table from source table t
CREATE TABLE `t2` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
) PARTITION BY RANGE (num) ) PARTITION BY RANGE (num)
(PARTITION p0 VALUES LESS THAN (1000000), (PARTITION p0 VALUES LESS THAN (100000),
PARTITION p1 VALUES LESS THAN (2000000), PARTITION p1 VALUES LESS THAN (200000),
PARTITION p2 VALUES LESS THAN (3000000), PARTITION p2 VALUES LESS THAN (300000),
PARTITION p3 VALUES LESS THAN (4000000), PARTITION p3 VALUES LESS THAN (400000),
PARTITION p4 VALUES LESS THAN (5000000), PARTITION p4 VALUES LESS THAN (500000),
PARTITION p5 VALUES LESS THAN (6000000), PARTITION p5 VALUES LESS THAN (600000),
PARTITION p6 VALUES LESS THAN (7000000), PARTITION p6 VALUES LESS THAN (700000),
PARTITION p7 VALUES LESS THAN MAXVALUE) as select * from t; PARTITION p7 VALUES LESS THAN MAXVALUE);
let $s = `select to_seconds(now())`; # put 1M rows into t1
INSERT INTO t1 values (null,null);
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
SELECT count(*) FROM t1;
let $maxq = 20;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint); CREATE TABLE t2 AS SELECT count(*) from t1;
SELECT count(*) from t1; DROP TABLE t2;
DROP TABLE t3;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TABLE t4 AS SELECT count(*) from t2; CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t4; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; # check that bulk fetch on is at least 2 times faster than bulk fetch off
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; }
let $maxrq = 30; let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint); CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
SELECT count(*) from t1 where num > 7000000; DROP TABLE t2;
DROP TABLE t3;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TABLE t4 AS SELECT count(*) from t2 where num > 7000000; CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t4; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; # check that bulk fetch on is at least 2 times faster than bulk fetch off
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
drop table t,t1,t2; drop table t1;
# Verify that index and range scans are not slow # Verify that index and range scans are not slow
# on temporary tables during create select statements # on tables during create select statements
# due to tokudb bulk fetch not being used # due to tokudb bulk fetch not being used
source include/have_tokudb.inc; source include/have_tokudb.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` ( CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
); );
# put 8M rows into t # put 1M rows into t1
INSERT INTO t values (null,null); INSERT INTO t1 values (null,null);
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; SELECT count(*) FROM t1;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create first table from source table t let $maxq = 10;
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL, set tokudb_bulk_fetch=ON;
`val` varchar(32) DEFAULT NULL, let $s = `select unix_timestamp()`;
PRIMARY KEY (`num`)
) as select * from t;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1; CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1;
DROP TEMPORARY TABLE t2; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par # Check that the time with bulk fetch off is at least twice that whith bulk fetch on
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_on $time_elapsed_off; }
if (!$verdict) { echo index $time_elapsed_on $time_elapsed_off; }
let $maxrq = 30; let $maxq = 30;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
SELECT count(*) from t1 where num > 7000000; CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Range scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 7000000; CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TEMPORARY TABLE t2; DROP TABLE t2;
inc $i; inc $i;
} }
let $time_elapsed_create_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_create_select seconds.;
# This check evaluates whether the time elapsed during the create select statement is on par # Check that the time with bulk fetch off is at least twice that whith bulk fetch on
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_create_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_on $time_elapsed_off; }
if (!$verdict) { echo range $time_elapsed_on $time_elapsed_off; }
drop table t,t1; drop table t1;
...@@ -8,6 +8,8 @@ disable_warnings; ...@@ -8,6 +8,8 @@ disable_warnings;
drop table if exists t; drop table if exists t;
enable_warnings; enable_warnings;
let $debug = 0;
CREATE TABLE `t` (id bigint not null auto_increment primary key, val bigint not null default 0); CREATE TABLE `t` (id bigint not null auto_increment primary key, val bigint not null default 0);
# put 8M rows into t # put 8M rows into t
...@@ -42,27 +44,28 @@ let $maxq = 10; ...@@ -42,27 +44,28 @@ let $maxq = 10;
# measure the time to do $maxq deletes from t that affect no rows with bulk fetch ON # measure the time to do $maxq deletes from t that affect no rows with bulk fetch ON
set tokudb_bulk_fetch = ON; set tokudb_bulk_fetch = ON;
let $s = `select to_seconds(now())`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
delete from t where val > 0; delete from t where val > 0;
inc $i; inc $i;
} }
let $time_elapsed_bf_on = `select to_seconds(now()) - $s`; let $time_elapsed_bf_on = `select unix_timestamp() - $s`;
# measure the time to do $maxq deletes from t that affect no rows with bulk fetch OFF # measure the time to do $maxq deletes from t that affect no rows with bulk fetch OFF
set tokudb_bulk_fetch = OFF; set tokudb_bulk_fetch = OFF;
let $s = `select to_seconds(now())`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
delete from t where val > 0; delete from t where val > 0;
inc $i; inc $i;
} }
let $time_elapsed_bf_off = `select to_seconds(now()) - $s`; let $time_elapsed_bf_off = `select unix_timestamp() - $s`;
# verify that a delete scan with bulk fetch ON is at least 2 times faster than with bulk fetch OFF # verify that a delete scan with bulk fetch ON is at least 2 times faster than with bulk fetch OFF
let $verdict = `select $time_elapsed_bf_off > $time_elapsed_bf_on && ($time_elapsed_bf_off - $time_elapsed_bf_on) / $time_elapsed_bf_on >= 2`; let $verdict = `select $time_elapsed_bf_on > 0 && $time_elapsed_bf_off >= 2 * $time_elapsed_bf_on`;
echo $verdict; echo $verdict;
if (!$verdict) { echo $time_elapsed_bf_on $time_elapsed_bf_off; } if ($debug) { echo range $verdict $time_elapsed_bf_on $time_elapsed_bf_off; }
if (!$verdict) { echo range $time_elapsed_bf_on $time_elapsed_bf_off; }
drop table t; drop table t;
...@@ -6,117 +6,95 @@ source include/have_tokudb.inc; ...@@ -6,117 +6,95 @@ source include/have_tokudb.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` ( CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
); );
# put 8M rows into t
INSERT INTO t values (null,null);
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create first table from source table t
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
# Create second table t2 that will serve as the target for the insert select statment # Create second table t2 that will serve as the target for the insert select statment
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`count` bigint(20) NOT NULL `count` bigint(20) NOT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1; );
let $s = `select to_seconds(now())`; # put 1M rows into t1
INSERT INTO t1 values (null,null);
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
SELECT count(*) FROM t1;
let $maxq = 20;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; INSERT into t2 SELECT count(*) from t1;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
INSERT into t2 SELECT count(*) from t1; INSERT into t2 SELECT count(*) from t1;
inc $i; inc $i;
} }
let $time_elapsed_insert_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data # check that bulk fetch on is at least 2 times faster than bulk fetch off
# which could be useful for debugging. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
#echo Index scans took $time_elapsed_insert_select seconds.;
# This check evaluates whether the time elapsed during the insert select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_insert_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; }
let $maxrq = 30; let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
SELECT count(*) from t1 where num > 7000000; INSERT into t2 SELECT count(*) from t1 where num > 700000;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# This check evaluates whether the time elapsed during the insert select statement is on par set tokudb_bulk_fetch=OFF;
# with the select statement, which will confirm that bulk fetch is in fact being used. let $s = `select unix_timestamp()`;
#echo Range scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
INSERT into t2 SELECT count(*) from t1 where num > 7000000; INSERT into t2 SELECT count(*) from t1 where num > 700000;
inc $i; inc $i;
} }
let $time_elapsed_insert_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# This check evaluates whether the time elapsed during the insert select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
#echo Range scans took $time_elapsed_insert_select seconds.;
# This check evaluates whether the time elapsed during the insert select statement is on par let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_insert_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
drop table t,t1,t2; drop table t1,t2;
...@@ -8,120 +8,98 @@ source include/have_tokudb.inc; ...@@ -8,120 +8,98 @@ source include/have_tokudb.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` ( CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
); );
# put 8M rows into t # put 1M rows into t1
INSERT INTO t values (null,null); INSERT INTO t1 values (null,null);
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t SELECT null,val FROM t; SELECT count(*) FROM t1;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create first table from source table t
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
# Create second table t2 that will serve as the target for the insert select statment # Create second table t2 that will serve as the target for the insert select statment
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`count` bigint(20) NOT NULL, `count` bigint(20) NOT NULL,
UNIQUE (num) UNIQUE (num)
) ENGINE=TokuDB DEFAULT CHARSET=latin1; );
let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; INSERT into t2 (num,count) SELECT NULL,count(*) from t1 on DUPLICATE KEY UPDATE count=count+1;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_select seconds.;
set tokudb_bulk_fetch=OFF;
let $s = `select to_seconds(now())`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 on DUPLICATE KEY UPDATE count=count+1; INSERT into t2 (num,count) SELECT NULL,count(*) from t1 on DUPLICATE KEY UPDATE count=count+1;
inc $i; inc $i;
} }
let $time_elapsed_insert_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_insert_select seconds.;
# This check evaluates whether the time elapsed during the insert select on duplicate key statement is on par # check that bulk fetch on is at least 2 times faster than bulk fetch off
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_insert_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; }
let $maxrq = 30; let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
SELECT count(*) from t1 where num > 7000000; INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 700000 on DUPLICATE KEY UPDATE count=count+1;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_select seconds.;
set tokudb_bulk_fetch=OFF;
let $s = `select to_seconds(now())`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxrq) { while ($i < $maxq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 7000000 on DUPLICATE KEY UPDATE count=count+1; INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 700000 on DUPLICATE KEY UPDATE count=count+1;
inc $i; inc $i;
} }
let $time_elapsed_insert_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data # check that bulk fetch on is at least 2 times faster than bulk fetch off
# which could be useful for debugging. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
#echo Range scans took $time_elapsed_insert_select seconds.;
# This check evaluates whether the time elapsed during the insert select on duplicate key statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_insert_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
enable_warnings; drop table t1,t2;
drop table t,t1,t2;
# Verify that index and range scans are not slow # Verify that index and range scans are not slow
# on tables during replace select and insert ignore statements # on tables during replace select statements
# due to tokudb bulk fetch not being used # due to tokudb bulk fetch not being used
source include/have_tokudb.inc; source include/have_tokudb.inc;
source include/big_test.inc; source include/big_test.inc;
set default_storage_engine='tokudb'; set default_storage_engine='tokudb';
disable_warnings; disable_warnings;
drop table if exists t,t1,t2; drop table if exists t1,t2;
enable_warnings; enable_warnings;
let $maxq = 10; let $debug = 0;
CREATE TABLE `t` ( CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL, `num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL, `val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`) PRIMARY KEY (`num`)
); );
# put 8M rows into t # Create second table t2 that will serve as the target for the insert select statment
INSERT INTO t values (null,null);
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
# Create first table from source table t
CREATE TABLE `t1` (
`num` int(10) unsigned NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) as select * from t;
# Create second table t2 that will serve as the target for the replace select statment
CREATE TABLE `t2` ( CREATE TABLE `t2` (
`count` bigint(20) NOT NULL `count` bigint(20) NOT NULL
) ENGINE=TokuDB DEFAULT CHARSET=latin1; );
let $s = `select to_seconds(now())`; # put 1M rows into t1
INSERT INTO t1 values (null,null);
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
INSERT INTO t1 SELECT null,val FROM t1;
SELECT count(*) FROM t1;
let $maxq = 20;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; REPLACE into t2 SELECT count(*) from t1;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
REPLACE into t2 SELECT count(*) from t1; REPLACE into t2 SELECT count(*) from t1;
inc $i; inc $i;
} }
let $time_elapsed_replace_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_replace_select seconds.;
# This check evaluates whether the time elapsed during the replace select statement is on par # check that bulk fetch on is at least 2 times faster than bulk fetch off
# with the select statement, which will confirm that bulk fetch is in fact being used. let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
let $verdict = `select abs($time_elapsed_replace_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo index $time_elapsed_off $time_elapsed_on; }
############################################################## let $maxq = 20;
let $s = `select to_seconds(now())`; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
SELECT count(*) from t1; REPLACE into t2 SELECT count(*) from t1 where num > 700000;
inc $i; inc $i;
} }
let $time_elapsed_select = `select to_seconds(now()) - $s`; let $time_elapsed_on = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data set tokudb_bulk_fetch=OFF;
# which could be useful for debugging. let $s = `select unix_timestamp()`;
#echo Index scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0; let $i = 0;
while ($i < $maxq) { while ($i < $maxq) {
INSERT IGNORE into t2 SELECT count(*) from t1; REPLACE into t2 SELECT count(*) from t1 where num > 700000;
inc $i; inc $i;
} }
let $time_elapsed_insert_ignore_select = `select to_seconds(now()) - $s`; let $time_elapsed_off = `select unix_timestamp() - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Index scans took $time_elapsed_insert_ignore_select seconds.;
# This check evaluates whether the time elapsed during the insert ignore select statement is on par let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_insert_ignore_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict; echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
################################################################## drop table t1,t2;
let $maxrq = 30;
let $s = `select to_seconds(now())`;
let $i = 0;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
inc $i;
}
let $time_elapsed_select = `select to_seconds(now()) - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0;
while ($i < $maxrq) {
REPLACE into t2 SELECT count(*) from t1 where num > 7000000;
inc $i;
}
let $time_elapsed_replace_select = `select to_seconds(now()) - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_replace_select seconds.;
# This check evaluates whether the time elapsed during the replace select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_replace_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict;
####################################################################
let $s = `select to_seconds(now())`;
let $i = 0;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
inc $i;
}
let $time_elapsed_select = `select to_seconds(now()) - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_select seconds.;
let $s = `select to_seconds(now())`;
let $i = 0;
while ($i < $maxrq) {
INSERT IGNORE into t2 SELECT count(*) from t1 where num > 7000000;
inc $i;
}
let $time_elapsed_insert_ignore_select = `select to_seconds(now()) - $s`;
# The following line can be used to display the time elapsed data
# which could be useful for debugging.
#echo Range scans took $time_elapsed_insert_ignore_select seconds.;
# This check evaluates whether the time elapsed during the insert ignore select statement is on par
# with the select statement, which will confirm that bulk fetch is in fact being used.
let $verdict = `select abs($time_elapsed_insert_ignore_select - $time_elapsed_select) <= $time_elapsed_select`;
echo $verdict;
#########################################################################
drop table t,t1,t2;
...@@ -66,9 +66,10 @@ let $time_bf_off = `select unix_timestamp() - $s`; ...@@ -66,9 +66,10 @@ let $time_bf_off = `select unix_timestamp() - $s`;
if ($debug) { echo index scans took $time_bf_off.; } if ($debug) { echo index scans took $time_bf_off.; }
# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on # check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on
let $verdict = `select $time_bf_off > $time_bf_on && $time_bf_off >= 1.5 * $time_bf_on`; let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`;
echo $verdict; echo $verdict;
if (!$verdict) { echo index scan $time_bf_on $time_bf_off; } if ($debug) { echo index $verdict $time_bf_on $time_bf_off; }
if (!$verdict) { echo index $time_bf_on $time_bf_off; }
set tokudb_bulk_fetch=ON; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`; let $s = `select unix_timestamp()`;
...@@ -93,8 +94,9 @@ let $time_bf_off = `select unix_timestamp() - $s`; ...@@ -93,8 +94,9 @@ let $time_bf_off = `select unix_timestamp() - $s`;
if ($debug) { echo range scans took $time_bf_off.; } if ($debug) { echo range scans took $time_bf_off.; }
# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on # check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on
let $verdict = `select $time_bf_off > $time_bf_on && $time_bf_off >= 1.5 * $time_bf_on`; let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`;
echo $verdict; echo $verdict;
if (!$verdict) { echo range scan $time_bf_on $time_bf_off; } if ($debug) { echo range $verdict $time_bf_on $time_bf_off; }
if (!$verdict) { echo range $time_bf_on $time_bf_off; }
drop table t; drop table t;
...@@ -9,7 +9,6 @@ disable_warnings; ...@@ -9,7 +9,6 @@ disable_warnings;
drop table if exists t; drop table if exists t;
enable_warnings; enable_warnings;
let $maxq = 20;
let $debug = 0; let $debug = 0;
# create the range partition table # create the range partition table
...@@ -51,6 +50,8 @@ INSERT INTO t SELECT null,val FROM t; ...@@ -51,6 +50,8 @@ INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t; INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t; SELECT count(*) FROM t;
let $maxq = 30;
set tokudb_bulk_fetch=ON; set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
...@@ -60,8 +61,6 @@ while ($i < $maxq) { ...@@ -60,8 +61,6 @@ while ($i < $maxq) {
} }
let $time_bf_on = `select unix_timestamp() - $s`; let $time_bf_on = `select unix_timestamp() - $s`;
if ($debug) { echo index scans took $time_bf_on; }
set tokudb_bulk_fetch=OFF; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
...@@ -71,11 +70,10 @@ while ($i < $maxq) { ...@@ -71,11 +70,10 @@ while ($i < $maxq) {
} }
let $time_bf_off = `select unix_timestamp() - $s`; let $time_bf_off = `select unix_timestamp() - $s`;
if ($debug) { echo index scans took $time_bf_off.; }
# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on # check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on
let $verdict = `select $time_bf_off > $time_bf_on && $time_bf_off >= 1.5 * $time_bf_on`; let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`;
echo $verdict; echo $verdict;
if ($debug) { echo index $verdict $time_bf_on $time_bf_off; }
if (!$verdict) { echo index scan $time_bf_on $time_bf_off; } if (!$verdict) { echo index scan $time_bf_on $time_bf_off; }
set tokudb_bulk_fetch=ON; set tokudb_bulk_fetch=ON;
...@@ -87,8 +85,6 @@ while ($i < $maxq) { ...@@ -87,8 +85,6 @@ while ($i < $maxq) {
} }
let $time_bf_on = `select unix_timestamp() - $s`; let $time_bf_on = `select unix_timestamp() - $s`;
if ($debug) { echo range scans took $time_bf_on; }
set tokudb_bulk_fetch=OFF; set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`; let $s = `select unix_timestamp()`;
let $i = 0; let $i = 0;
...@@ -98,11 +94,10 @@ while ($i < $maxq) { ...@@ -98,11 +94,10 @@ while ($i < $maxq) {
} }
let $time_bf_off = `select unix_timestamp() - $s`; let $time_bf_off = `select unix_timestamp() - $s`;
if ($debug) { echo range scans took $time_bf_off.; }
# check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on # check that the scan time with bulk fetch off is at least 1.5 times as long as with bulk fetch on
let $verdict = `select $time_bf_off > $time_bf_on && $time_bf_off >= 1.5 * $time_bf_on`; let $verdict = `select $time_bf_on > 0 && $time_bf_off >= 1.5 * $time_bf_on`;
echo $verdict; echo $verdict;
if (!$verdict) { echo range scan $time_bf_on $time_bf_off; } if ($debug) { echo range $verdict $time_bf_on $time_bf_off; }
if (!$verdict) { echo range $time_bf_on $time_bf_off; }
drop table t; drop table t;
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