Commit 753e4f3f authored by Rich Prohaska's avatar Rich Prohaska

DB-724 speed up and simplify the bulk fetch tests

parent 665a9b6e
......@@ -98,6 +98,36 @@ count(*)
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
SELECT count(*) from t;
count(*)
1048576
set tokudb_bulk_fetch=OFF;
SELECT count(*) from t;
count(*)
......@@ -159,6 +189,36 @@ count(*)
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
SELECT count(*) from t;
count(*)
1048576
1
set tokudb_bulk_fetch=ON;
SELECT count(*) from t where num > 700000;
......@@ -221,6 +281,36 @@ count(*)
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
SELECT count(*) from t where num > 700000;
count(*)
348576
set tokudb_bulk_fetch=OFF;
SELECT count(*) from t where num > 700000;
count(*)
......@@ -282,5 +372,35 @@ count(*)
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
SELECT count(*) from t where num > 700000;
count(*)
348576
1
drop table t;
......@@ -6,64 +6,56 @@ source include/have_tokudb.inc;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
let $debug = 0;
CREATE TABLE `t` (
CREATE TABLE `t1` (
`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 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;
# 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 $s = `select to_seconds(now())`;
let $maxq = 10;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
SELECT count(*) from t1;
CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
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;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1;
......@@ -71,48 +63,41 @@ while ($i < $maxq) {
inc $i;
}
let $time_elapsed_create_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 Index scans took $time_elapsed_create_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# Check that the time with bulk fetch off is at least twice that whith bulk fetch on
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
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;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
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;
while ($i < $maxrq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_create_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 Index scans took $time_elapsed_create_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# Check that the time with bulk fetch off is at least twice that whith bulk fetch on
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
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;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2,t3;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
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;
let $debug = 0;
# Create source hash partitioned table from source table t
CREATE TABLE `t2` (
`num` int(10) unsigned NOT NULL,
CREATE TABLE `t1` (
`num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) PARTITION BY HASH (num)
PARTITIONS 8 as select * from t;
let $s = `select to_seconds(now())`;
) PARTITION BY HASH (num) PARTITIONS 8;
# 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;
while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint);
SELECT count(*) from t1;
DROP TABLE t3;
CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
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 Index scans took $time_elapsed_select seconds.;
let $time_elapsed_on = `select unix_timestamp() - $s`;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
CREATE TABLE t3 AS SELECT count(*) from t2;
DROP TABLE t3;
CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_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 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`;
# 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`;
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;
while ($i < $maxrq) {
CREATE TABLE `t3` (`x` bigint);
SELECT count(*) from t1 where num > 7000000;
DROP TABLE t3;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
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 Index scans took $time_elapsed_select seconds.;
let $time_elapsed_on = `select unix_timestamp() - $s`;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxrq) {
CREATE TABLE t3 AS SELECT count(*) from t2 where num > 7000000;
DROP TABLE t3;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_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 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`;
# 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`;
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;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
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 range partitioned table from source table t
CREATE TABLE `t2` (
`num` int(10) unsigned NOT NULL,
`num` int(10) unsigned auto_increment NOT NULL,
`val` varchar(32) DEFAULT NULL,
PRIMARY KEY (`num`)
) PARTITION BY RANGE (num)
(PARTITION p0 VALUES LESS THAN (1000000),
PARTITION p1 VALUES LESS THAN (2000000),
PARTITION p2 VALUES LESS THAN (3000000),
PARTITION p3 VALUES LESS THAN (4000000),
PARTITION p4 VALUES LESS THAN (5000000),
PARTITION p5 VALUES LESS THAN (6000000),
PARTITION p6 VALUES LESS THAN (7000000),
PARTITION p7 VALUES LESS THAN MAXVALUE) as select * from t;
let $s = `select to_seconds(now())`;
(PARTITION p0 VALUES LESS THAN (100000),
PARTITION p1 VALUES LESS THAN (200000),
PARTITION p2 VALUES LESS THAN (300000),
PARTITION p3 VALUES LESS THAN (400000),
PARTITION p4 VALUES LESS THAN (500000),
PARTITION p5 VALUES LESS THAN (600000),
PARTITION p6 VALUES LESS THAN (700000),
PARTITION p7 VALUES LESS THAN MAXVALUE);
# 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;
while ($i < $maxq) {
CREATE TABLE `t3` (`x` bigint);
SELECT count(*) from t1;
DROP TABLE t3;
CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
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 Index scans took $time_elapsed_select seconds.;
let $time_elapsed_on = `select unix_timestamp() - $s`;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
CREATE TABLE t4 AS SELECT count(*) from t2;
DROP TABLE t4;
CREATE TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_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 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`;
# 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`;
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;
while ($i < $maxrq) {
CREATE TABLE `t3` (`x` bigint);
SELECT count(*) from t1 where num > 7000000;
DROP TABLE t3;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
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;
while ($i < $maxrq) {
CREATE TABLE t4 AS SELECT count(*) from t2 where num > 7000000;
DROP TABLE t4;
while ($i < $maxq) {
CREATE TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_off = `select unix_timestamp() - $s`;
let $time_elapsed_create_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 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`;
# 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`;
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
# on temporary tables during create select statements
# on tables during create select statements
# due to tokudb bulk fetch not being used
source include/have_tokudb.inc;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
let $debug = 0;
CREATE TABLE `t` (
CREATE TABLE `t1` (
`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;
# 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;
# 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;
while ($i < $maxq) {
SELECT count(*) from t1;
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1;
DROP TABLE t2;
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;
while ($i < $maxq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1;
DROP TEMPORARY TABLE t2;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_create_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 Index scans took $time_elapsed_create_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# Check that the time with bulk fetch off is at least twice that whith bulk fetch on
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
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;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
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.;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxrq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 7000000;
DROP TEMPORARY TABLE t2;
while ($i < $maxq) {
CREATE TEMPORARY TABLE t2 AS SELECT count(*) from t1 where num > 700000;
DROP TABLE t2;
inc $i;
}
let $time_elapsed_create_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_create_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# Check that the time with bulk fetch off is at least twice that whith bulk fetch on
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
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;
drop table if exists t;
enable_warnings;
let $debug = 0;
CREATE TABLE `t` (id bigint not null auto_increment primary key, val bigint not null default 0);
# put 8M rows into t
......@@ -42,27 +44,28 @@ let $maxq = 10;
# measure the time to do $maxq deletes from t that affect no rows with bulk fetch ON
set tokudb_bulk_fetch = ON;
let $s = `select to_seconds(now())`;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
delete from t where val > 0;
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
set tokudb_bulk_fetch = OFF;
let $s = `select to_seconds(now())`;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
delete from t where val > 0;
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
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;
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;
......@@ -6,117 +6,95 @@ source include/have_tokudb.inc;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
let $debug = 0;
CREATE TABLE `t` (
CREATE TABLE `t1` (
`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 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 TABLE `t2` (
`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;
while ($i < $maxq) {
SELECT count(*) from t1;
INSERT into t2 SELECT count(*) from t1;
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;
while ($i < $maxq) {
INSERT into t2 SELECT count(*) from t1;
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 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`;
# 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`;
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;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
INSERT into t2 SELECT count(*) from t1 where num > 700000;
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
# with the select statement, which will confirm that bulk fetch is in fact being used.
#echo Range 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;
while ($i < $maxrq) {
INSERT into t2 SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
INSERT into t2 SELECT count(*) from t1 where num > 700000;
inc $i;
}
let $time_elapsed_insert_select = `select to_seconds(now()) - $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.;
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.
let $verdict = `select abs($time_elapsed_insert_select - $time_elapsed_select) <= $time_elapsed_select`;
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
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;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
let $debug = 0;
CREATE TABLE `t` (
CREATE TABLE `t1` (
`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 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;
# 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;
# Create second table t2 that will serve as the target for the insert select statment
CREATE TABLE `t2` (
`num` int(10) unsigned auto_increment NOT NULL,
`count` bigint(20) NOT NULL,
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;
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;
}
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 Index scans took $time_elapsed_select seconds.;
let $time_elapsed_on = `select unix_timestamp() - $s`;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 on DUPLICATE KEY UPDATE count=count+1;
inc $i;
}
let $time_elapsed_insert_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 Index scans took $time_elapsed_insert_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# 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`;
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;
while ($i < $maxrq) {
SELECT count(*) from t1 where num > 7000000;
while ($i < $maxq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 700000 on DUPLICATE KEY UPDATE count=count+1;
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 $time_elapsed_on = `select unix_timestamp() - $s`;
let $s = `select to_seconds(now())`;
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
while ($i < $maxrq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 7000000 on DUPLICATE KEY UPDATE count=count+1;
while ($i < $maxq) {
INSERT into t2 (num,count) SELECT NULL,count(*) from t1 where num > 700000 on DUPLICATE KEY UPDATE count=count+1;
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 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`;
# 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`;
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 t,t1,t2;
drop table t1,t2;
# 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
source include/have_tokudb.inc;
source include/big_test.inc;
set default_storage_engine='tokudb';
disable_warnings;
drop table if exists t,t1,t2;
drop table if exists t1,t2;
enable_warnings;
let $maxq = 10;
let $debug = 0;
CREATE TABLE `t` (
CREATE TABLE `t1` (
`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 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 second table t2 that will serve as the target for the insert select statment
CREATE TABLE `t2` (
`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;
while ($i < $maxq) {
SELECT count(*) from t1;
REPLACE into t2 SELECT count(*) from t1;
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;
while ($i < $maxq) {
REPLACE into t2 SELECT count(*) from t1;
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 Index scans took $time_elapsed_replace_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
# 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`;
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;
while ($i < $maxq) {
SELECT count(*) from t1;
REPLACE into t2 SELECT count(*) from t1 where num > 700000;
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;
while ($i < $maxq) {
INSERT IGNORE into t2 SELECT count(*) from t1;
REPLACE into t2 SELECT count(*) from t1 where num > 700000;
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 Index scans took $time_elapsed_insert_ignore_select seconds.;
let $time_elapsed_off = `select unix_timestamp() - $s`;
# 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`;
let $verdict = `select $time_elapsed_on > 0 && $time_elapsed_off >= 2 * $time_elapsed_on`;
echo $verdict;
if ($debug) { echo range $verdict $time_elapsed_off $time_elapsed_on; }
if (!$verdict) { echo range $time_elapsed_off $time_elapsed_on; }
##################################################################
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;
drop table t1,t2;
......@@ -66,9 +66,10 @@ 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
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;
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;
let $s = `select unix_timestamp()`;
......@@ -93,8 +94,9 @@ 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
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;
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;
......@@ -9,7 +9,6 @@ disable_warnings;
drop table if exists t;
enable_warnings;
let $maxq = 20;
let $debug = 0;
# create the range partition table
......@@ -51,6 +50,8 @@ INSERT INTO t SELECT null,val FROM t;
INSERT INTO t SELECT null,val FROM t;
SELECT count(*) FROM t;
let $maxq = 30;
set tokudb_bulk_fetch=ON;
let $s = `select unix_timestamp()`;
let $i = 0;
......@@ -60,8 +61,6 @@ while ($i < $maxq) {
}
let $time_bf_on = `select unix_timestamp() - $s`;
if ($debug) { echo index scans took $time_bf_on; }
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
......@@ -71,11 +70,10 @@ while ($i < $maxq) {
}
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
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;
if ($debug) { echo index $verdict $time_bf_on $time_bf_off; }
if (!$verdict) { echo index scan $time_bf_on $time_bf_off; }
set tokudb_bulk_fetch=ON;
......@@ -87,8 +85,6 @@ while ($i < $maxq) {
}
let $time_bf_on = `select unix_timestamp() - $s`;
if ($debug) { echo range scans took $time_bf_on; }
set tokudb_bulk_fetch=OFF;
let $s = `select unix_timestamp()`;
let $i = 0;
......@@ -98,11 +94,10 @@ while ($i < $maxq) {
}
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
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;
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;
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