10 Feb '19
revision-id: 3955d2a1539e7e41e3457c99f773d90c90f4f90f (mariadb-10.3.6-112-g3955d2a1539)
parent(s): 15fe81c571ef81ec834ac91f96c9adb4343ecd05
author: Galina Shalygina
committer: Galina Shalygina
timestamp: 2019-02-10 22:36:46 +0300
message:
MDEV-18413: Find constraint correlated indexes
Find indexes of one table which parts participate in one constraint.
These indexes are called constraint correlated.
New methods: TABLE::find_constraint_correlated_indexes() and
virtual method check_index_dependence() were added.
For each index it's own constraint correlated index map was created
where all indexes that are constraint correlated with the current are
marked.
The results of this task are used for MDEV-16188 (Use in-memory
PK filters built from range index scans).
---
mysql-test/main/rowid_filter.result | 765 +++++++++++++++++++++++++++++
mysql-test/main/rowid_filter.test | 100 +++-
mysql-test/main/rowid_filter_innodb.result | 765 +++++++++++++++++++++++++++++
sql/item.h | 7 +
sql/rowid_filter.cc | 14 +-
sql/structs.h | 2 +
sql/table.cc | 76 +++
sql/table.h | 3 +
8 files changed, 1726 insertions(+), 6 deletions(-)
diff --git a/mysql-test/main/rowid_filter.result b/mysql-test/main/rowid_filter.result
index 4ad83adcadb..34df3035051 100644
--- a/mysql-test/main/rowid_filter.result
+++ b/mysql-test/main/rowid_filter.result
@@ -1174,5 +1174,770 @@ o_orderkey l_linenumber l_shipdate o_totalprice
5895 4 1997-03-03 201419.83
5895 5 1997-04-30 201419.83
5895 6 1997-04-19 201419.83
+#
+# MDEV-18413: find constraint correlated indexes
+#
+ALTER TABLE lineitem ADD CONSTRAINT l_date CHECK(l_shipdate < l_receiptdate);
+# Filter on l_shipdate is not used because it participates in
+# the same constraint as l_receiptdate.
+# Access is made on l_receiptdate.
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "rows": 18,
+ "filtered": 0.5662,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 8.7333,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 8.73 14.29 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "r_loops": 1,
+ "rows": 18,
+ "r_rows": 18,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 0.5662,
+ "r_filtered": 38.889,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 7,
+ "rows": 1,
+ "r_rows": 1,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 8.7333,
+ "r_filtered": 14.286,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+l_shipdate l_receiptdate o_totalprice
+1996-10-07 1996-10-08 202623.92
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "rows": 18,
+ "filtered": 0.5662,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 8.7333,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 8.73 14.29 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "r_loops": 1,
+ "rows": 18,
+ "r_rows": 18,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 0.5662,
+ "r_filtered": 38.889,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 7,
+ "rows": 1,
+ "r_rows": 1,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 8.7333,
+ "r_filtered": 14.286,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+l_shipdate l_receiptdate o_totalprice
+1996-10-07 1996-10-08 202623.92
+ALTER TABLE orders ADD COLUMN o_totaldiscount double;
+UPDATE orders SET o_totaldiscount = o_totalprice*(o_custkey/1000);
+CREATE INDEX i_o_totaldiscount on orders(o_totaldiscount);
+ALTER TABLE orders ADD CONSTRAINT o_price CHECK(o_totalprice > o_totaldiscount);
+# Filter on o_totalprice is not used because it participates in
+# the same constraint as o_discount.
+# Access is made on o_discount.
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 39,
+ "filtered": 3.2667,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.27 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 39,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.2667,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 39,
+ "filtered": 3.2667,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 3.27 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 39,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.2667,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+CREATE VIEW v1 AS
+SELECT * FROM orders
+WHERE o_orderdate BETWEEN '1992-12-01' AND '1997-01-01';
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 39,
+ "filtered": 1.9905,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 1.99 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 39,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 1.9905,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 39,
+ "filtered": 1.9905,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 39 41.00 1.99 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 39,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 1.9905,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+ALTER TABLE lineitem DROP CONSTRAINT l_date;
+ALTER TABLE orders DROP CONSTRAINT o_price;
+ALTER TABLE orders DROP COLUMN o_totaldiscount;
+DROP VIEW v1;
DROP DATABASE dbt3_s001;
set @@use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/main/rowid_filter.test b/mysql-test/main/rowid_filter.test
index e1b0c69d470..0e8a3de9c8f 100644
--- a/mysql-test/main/rowid_filter.test
+++ b/mysql-test/main/rowid_filter.test
@@ -127,7 +127,105 @@ eval $without_filter ANALYZE FORMAT=JSON $q4;
--sorted_result
eval $without_filter $q4;
+--echo #
+--echo # MDEV-18413: find constraint correlated indexes
+--echo #
+
+ALTER TABLE lineitem ADD CONSTRAINT l_date CHECK(l_shipdate < l_receiptdate);
+
+--echo # Filter on l_shipdate is not used because it participates in
+--echo # the same constraint as l_receiptdate.
+--echo # Access is made on l_receiptdate.
+let $q5=
+SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+ l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+ l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+ o_totalprice BETWEEN 200000 AND 250000;
+
+eval $with_filter EXPLAIN $q5;
+eval $with_filter EXPLAIN FORMAT=JSON $q5;
+eval $with_filter ANALYZE $q5;
+--source include/analyze-format.inc
+eval $with_filter ANALYZE FORMAT=JSON $q5;
+--sorted_result
+eval $with_filter $q5;
+
+eval $without_filter EXPLAIN $q5;
+eval $without_filter EXPLAIN FORMAT=JSON $q5;
+eval $without_filter ANALYZE $q5;
+--source include/analyze-format.inc
+eval $without_filter ANALYZE FORMAT=JSON $q5;
+--sorted_result
+eval $without_filter $q5;
+
+ALTER TABLE orders ADD COLUMN o_totaldiscount double;
+UPDATE orders SET o_totaldiscount = o_totalprice*(o_custkey/1000);
+CREATE INDEX i_o_totaldiscount on orders(o_totaldiscount);
+
+ALTER TABLE orders ADD CONSTRAINT o_price CHECK(o_totalprice > o_totaldiscount);
+
+--echo # Filter on o_totalprice is not used because it participates in
+--echo # the same constraint as o_discount.
+--echo # Access is made on o_discount.
+let $q6=
+SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+ o_totaldiscount BETWEEN 18000 AND 20000 AND
+ o_totalprice BETWEEN 200000 AND 220000 AND
+ l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+
+eval $with_filter EXPLAIN $q6;
+eval $with_filter EXPLAIN FORMAT=JSON $q6;
+eval $with_filter ANALYZE $q6;
+--source include/analyze-format.inc
+eval $with_filter ANALYZE FORMAT=JSON $q6;
+--sorted_result
+eval $with_filter $q6;
+
+eval $without_filter EXPLAIN $q6;
+eval $without_filter EXPLAIN FORMAT=JSON $q6;
+eval $without_filter ANALYZE $q6;
+--source include/analyze-format.inc
+eval $without_filter ANALYZE FORMAT=JSON $q6;
+--sorted_result
+eval $without_filter $q6;
+
+CREATE VIEW v1 AS
+SELECT * FROM orders
+WHERE o_orderdate BETWEEN '1992-12-01' AND '1997-01-01';
+
+let $q7=
+SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+ o_totaldiscount BETWEEN 18000 AND 20000 AND
+ o_totalprice BETWEEN 200000 AND 220000 AND
+ l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+
+eval $with_filter EXPLAIN $q7;
+eval $with_filter EXPLAIN FORMAT=JSON $q7;
+eval $with_filter ANALYZE $q7;
+--source include/analyze-format.inc
+eval $with_filter ANALYZE FORMAT=JSON $q7;
+--sorted_result
+eval $with_filter $q7;
+
+eval $without_filter EXPLAIN $q7;
+eval $without_filter EXPLAIN FORMAT=JSON $q7;
+eval $without_filter ANALYZE $q7;
+--source include/analyze-format.inc
+eval $without_filter ANALYZE FORMAT=JSON $q7;
+--sorted_result
+eval $without_filter $q7;
+
+ALTER TABLE lineitem DROP CONSTRAINT l_date;
+ALTER TABLE orders DROP CONSTRAINT o_price;
+ALTER TABLE orders DROP COLUMN o_totaldiscount;
+DROP VIEW v1;
+
DROP DATABASE dbt3_s001;
set @@use_stat_tables=@save_use_stat_tables;
-
diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result
index f72db6b6bc0..65f68968f6e 100644
--- a/mysql-test/main/rowid_filter_innodb.result
+++ b/mysql-test/main/rowid_filter_innodb.result
@@ -1103,6 +1103,771 @@ o_orderkey l_linenumber l_shipdate o_totalprice
5895 4 1997-03-03 201419.83
5895 5 1997-04-30 201419.83
5895 6 1997-04-19 201419.83
+#
+# MDEV-18413: find constraint correlated indexes
+#
+ALTER TABLE lineitem ADD CONSTRAINT l_date CHECK(l_shipdate < l_receiptdate);
+# Filter on l_shipdate is not used because it participates in
+# the same constraint as l_receiptdate.
+# Access is made on l_receiptdate.
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "rows": 18,
+ "filtered": 0.5662,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 5.6667,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 5.67 14.29 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "r_loops": 1,
+ "rows": 18,
+ "r_rows": 18,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 0.5662,
+ "r_filtered": 38.889,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 7,
+ "rows": 1,
+ "r_rows": 1,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 5.6667,
+ "r_filtered": 14.286,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+l_shipdate l_receiptdate o_totalprice
+1996-10-07 1996-10-08 202623.92
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "rows": 18,
+ "filtered": 0.5662,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "rows": 1,
+ "filtered": 5.6667,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE lineitem range PRIMARY,i_l_shipdate,i_l_receiptdate,i_l_orderkey,i_l_orderkey_quantity i_l_receiptdate 4 NULL 18 18.00 0.57 38.89 Using index condition; Using where
+1 SIMPLE orders eq_ref PRIMARY,i_o_totalprice PRIMARY 4 dbt3_s001.lineitem.l_orderkey 1 1.00 5.67 14.29 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_receiptdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "i_l_receiptdate",
+ "key_length": "4",
+ "used_key_parts": ["l_receiptDATE"],
+ "r_loops": 1,
+ "rows": 18,
+ "r_rows": 18,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 0.5662,
+ "r_filtered": 38.889,
+ "index_condition": "lineitem.l_receiptDATE between '1996-10-05' and '1996-10-10'",
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-10-10'"
+ },
+ "table": {
+ "table_name": "orders",
+ "access_type": "eq_ref",
+ "possible_keys": ["PRIMARY", "i_o_totalprice"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["o_orderkey"],
+ "ref": ["dbt3_s001.lineitem.l_orderkey"],
+ "r_loops": 7,
+ "rows": 1,
+ "r_rows": 1,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 5.6667,
+ "r_filtered": 14.286,
+ "attached_condition": "orders.o_totalprice between 200000 and 250000"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT l_shipdate, l_receiptdate, o_totalprice
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-10-10' AND
+l_receiptdate BETWEEN '1996-10-05' AND '1996-10-10' AND
+o_totalprice BETWEEN 200000 AND 250000;
+l_shipdate l_receiptdate o_totalprice
+1996-10-07 1996-10-08 202623.92
+ALTER TABLE orders ADD COLUMN o_totaldiscount double;
+UPDATE orders SET o_totaldiscount = o_totalprice*(o_custkey/1000);
+CREATE INDEX i_o_totaldiscount on orders(o_totaldiscount);
+ALTER TABLE orders ADD CONSTRAINT o_price CHECK(o_totalprice > o_totaldiscount);
+# Filter on o_totalprice is not used because it participates in
+# the same constraint as o_discount.
+# Access is made on o_discount.
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 41,
+ "filtered": 3.3333,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 41.00 3.33 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 41,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.3333,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 41,
+ "filtered": 3.3333,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 41.00 3.33 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY", "i_o_totalprice", "i_o_totaldiscount"],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 41,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.3333,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM orders, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+CREATE VIEW v1 AS
+SELECT * FROM orders
+WHERE o_orderdate BETWEEN '1992-12-01' AND '1997-01-01';
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=on' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 41,
+ "filtered": 2.0711,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 41.00 2.07 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=on' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 41,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 2.0711,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=on' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 Using where
+set statement optimizer_switch='rowid_filter=off' for EXPLAIN FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "rows": 41,
+ "filtered": 2.0711,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "rows": 4,
+ "filtered": 3.0475,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for ANALYZE SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE orders range PRIMARY,i_o_orderdate,i_o_totalprice,i_o_totaldiscount i_o_totaldiscount 9 NULL 41 41.00 2.07 2.44 Using index condition; Using where
+1 SIMPLE lineitem ref PRIMARY,i_l_shipdate,i_l_orderkey,i_l_orderkey_quantity PRIMARY 4 dbt3_s001.orders.o_orderkey 4 6.00 3.05 66.67 Using where
+set statement optimizer_switch='rowid_filter=off' for ANALYZE FORMAT=JSON SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "orders",
+ "access_type": "range",
+ "possible_keys": [
+ "PRIMARY",
+ "i_o_orderdate",
+ "i_o_totalprice",
+ "i_o_totaldiscount"
+ ],
+ "key": "i_o_totaldiscount",
+ "key_length": "9",
+ "used_key_parts": ["o_totaldiscount"],
+ "r_loops": 1,
+ "rows": 41,
+ "r_rows": 41,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 2.0711,
+ "r_filtered": 2.439,
+ "index_condition": "orders.o_totaldiscount between 18000 and 20000",
+ "attached_condition": "orders.o_totalprice between 200000 and 220000 and orders.o_orderDATE between '1992-12-01' and '1997-01-01'"
+ },
+ "table": {
+ "table_name": "lineitem",
+ "access_type": "ref",
+ "possible_keys": [
+ "PRIMARY",
+ "i_l_shipdate",
+ "i_l_orderkey",
+ "i_l_orderkey_quantity"
+ ],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["l_orderkey"],
+ "ref": ["dbt3_s001.orders.o_orderkey"],
+ "r_loops": 1,
+ "rows": 4,
+ "r_rows": 6,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 3.0475,
+ "r_filtered": 66.667,
+ "attached_condition": "lineitem.l_shipDATE between '1996-10-01' and '1996-12-01'"
+ }
+ }
+}
+set statement optimizer_switch='rowid_filter=off' for SELECT o_totaldiscount, o_totalprice, l_shipdate
+FROM v1, lineitem
+WHERE o_orderkey=l_orderkey AND
+o_totaldiscount BETWEEN 18000 AND 20000 AND
+o_totalprice BETWEEN 200000 AND 220000 AND
+l_shipdate BETWEEN '1996-10-01' AND '1996-12-01';
+o_totaldiscount o_totalprice l_shipdate
+18016.04288 219707.84 1996-10-02
+18016.04288 219707.84 1996-10-17
+18016.04288 219707.84 1996-11-04
+18016.04288 219707.84 1996-11-14
+ALTER TABLE lineitem DROP CONSTRAINT l_date;
+ALTER TABLE orders DROP CONSTRAINT o_price;
+ALTER TABLE orders DROP COLUMN o_totaldiscount;
+DROP VIEW v1;
DROP DATABASE dbt3_s001;
set @@use_stat_tables=@save_use_stat_tables;
SET SESSION STORAGE_ENGINE=DEFAULT;
diff --git a/sql/item.h b/sql/item.h
index fd9261c3424..f8580a80edf 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1962,6 +1962,12 @@ class Item: public Value_source,
virtual bool check_valid_arguments_processor(void *arg) { return 0; }
virtual bool update_vcol_processor(void *arg) { return 0; }
virtual bool set_fields_as_dependent_processor(void *arg) { return 0; }
+ /*
+ Find if some of the key parts of table keys (the reference on table is
+ passed as an argument) participate in the expression.
+ If there is some, sets a bit for this key in the proper key map.
+ */
+ virtual bool check_index_dependence(void *arg) { return 0; }
/*============== End of Item processor list ======================*/
virtual Item *get_copy(THD *thd)=0;
@@ -3464,6 +3470,7 @@ class Item_field :public Item_ident,
DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY);
return field->get_geometry_type();
}
+ bool check_index_dependence(void *arg);
friend class Item_default_value;
friend class Item_insert_value;
friend class st_select_lex_unit;
diff --git a/sql/rowid_filter.cc b/sql/rowid_filter.cc
index c899236e336..cea00097665 100644
--- a/sql/rowid_filter.cc
+++ b/sql/rowid_filter.cc
@@ -159,9 +159,12 @@ void TABLE::prune_range_rowid_filters()
Range_rowid_filter_cost_info **filter_ptr_2= filter_ptr_1 + 1;
for (j= i+1; j < range_rowid_filter_cost_info_elems; j++, filter_ptr_2++)
{
- key_map map= key_info[key_no].overlapped;
- map.intersect(key_info[(*filter_ptr_2)->key_no].overlapped);
- if (map.is_clear_all())
+ key_map map_1= key_info[key_no].overlapped;
+ map_1.merge(key_info[key_no].constraint_correlated);
+ key_map map_2= key_info[(*filter_ptr_2)->key_no].overlapped;
+ map_2.merge(key_info[(*filter_ptr_2)->key_no].constraint_correlated);
+ map_1.intersect(map_2);
+ if (map_1.is_clear_all())
{
(*filter_ptr_1)->abs_independent.set_bit((*filter_ptr_2)->key_no);
(*filter_ptr_2)->abs_independent.set_bit(key_no);
@@ -390,7 +393,8 @@ TABLE::best_range_rowid_filter_for_partial_join(uint access_key_no,
Range_rowid_filter_cost_info *best_filter= 0;
double best_filter_gain= 0;
- key_map *overlapped= &key_info[access_key_no].overlapped;
+ key_map no_filter_usage= key_info[access_key_no].overlapped;
+ no_filter_usage.merge(key_info[access_key_no].constraint_correlated);
for (uint i= 0; i < range_rowid_filter_cost_info_elems ; i++)
{
double curr_gain = 0;
@@ -401,7 +405,7 @@ TABLE::best_range_rowid_filter_for_partial_join(uint access_key_no,
the index by which the table is accessed
*/
if ((filter->key_no == access_key_no) ||
- overlapped->is_set(filter->key_no))
+ no_filter_usage.is_set(filter->key_no))
continue;
if (records < filter->cross_x)
diff --git a/sql/structs.h b/sql/structs.h
index 8aec29bac41..3628cd01748 100644
--- a/sql/structs.h
+++ b/sql/structs.h
@@ -124,6 +124,8 @@ typedef struct st_key {
(only key parts from key definitions are taken into account)
*/
key_map overlapped;
+ /* Set of keys constraint correlated with this key */
+ key_map constraint_correlated;
LEX_CSTRING name;
uint block_size;
enum ha_key_alg algorithm;
diff --git a/sql/table.cc b/sql/table.cc
index 6676ce5447d..c96a8db57e7 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1194,6 +1194,8 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
goto end;
}
+ table->find_constraint_correlated_indexes();
+
res=0;
end:
thd->restore_active_arena(table->expr_arena, &backup_arena);
@@ -1274,6 +1276,80 @@ void TABLE_SHARE::set_overlapped_keys()
}
+bool Item_field::check_index_dependence(void *arg)
+{
+ TABLE *table= (TABLE *)arg;
+
+ KEY *key= table->key_info;
+ for (uint j= 0; j < table->s->keys; j++, key++)
+ {
+ if (table->constraint_dependent_keys.is_set(j))
+ continue;
+
+ KEY_PART_INFO *key_part= key->key_part;
+ uint n= key->user_defined_key_parts;
+
+ for (uint k= 0; k < n; k++, key_part++)
+ {
+ if (this->field == key_part->field)
+ {
+ table->constraint_dependent_keys.set_bit(j);
+ break;
+ }
+ }
+ }
+ return false;
+}
+
+
+/**
+ @brief
+ Find keys that occur in the same constraint on this table
+
+ @details
+ Constraints on this table are checked only.
+
+ The method goes through constraints list trying to find at
+ least two keys which parts participate in some constraint.
+ These keys are called constraint correlated.
+
+ Each key has its own key map with the information about with
+ which keys it is constraint correlated. Bit in this map is set
+ only if keys are constraint correlated.
+ This method fills each keys constraint correlated key map.
+*/
+
+void TABLE::find_constraint_correlated_indexes()
+{
+ if (s->keys == 0)
+ return;
+
+ KEY *key= key_info;
+ for (uint i= 0; i < s->keys; i++, key++)
+ {
+ key->constraint_correlated.clear_all();
+ key->constraint_correlated.set_bit(i);
+ }
+
+ if (!check_constraints)
+ return;
+
+ for (Virtual_column_info **chk= check_constraints ; *chk ; chk++)
+ {
+ constraint_dependent_keys.clear_all();
+ (*chk)->expr->walk(&Item::check_index_dependence, 0, this);
+
+ if (constraint_dependent_keys.bits_set() <= 1)
+ continue;
+
+ uint key_no= 0;
+ key_map::Iterator ki(constraint_dependent_keys);
+ while ((key_no= ki++) != key_map::Iterator::BITMAP_END)
+ key_info[key_no].constraint_correlated.merge(constraint_dependent_keys);
+ }
+}
+
+
/**
Read data from a binary .frm file image into a TABLE_SHARE
diff --git a/sql/table.h b/sql/table.h
index 0a2dc63b068..377176fd10e 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1133,6 +1133,8 @@ struct TABLE
key_map keys_in_use_for_group_by;
/* Map of keys that can be used to calculate ORDER BY without sorting */
key_map keys_in_use_for_order_by;
+ /* Map of keys dependent on some constraint */
+ key_map constraint_dependent_keys;
KEY *key_info; /* data of keys in database */
Field **field; /* Pointer to fields */
@@ -1566,6 +1568,7 @@ struct TABLE
int delete_row();
void vers_update_fields();
void vers_update_end();
+ void find_constraint_correlated_indexes();
/** Number of additional fields used in versioned tables */
#define VERSIONING_FIELDS 2
1
0
[Commits] 53730224efd: Improve histogram collection performance by sampling
by vicentiu@mariadb.org 10 Feb '19
by vicentiu@mariadb.org 10 Feb '19
10 Feb '19
revision-id: 53730224efd987f97a6cc968ff5214ee499d84e0 (mariadb-10.4.1-163-g53730224efd)
parent(s): 3c305d3f1951f1667f84e48ddd98674c6318c39d
author: Vicențiu Ciorbaru
committer: Vicențiu Ciorbaru
timestamp: 2019-02-10 19:54:50 +0200
message:
Improve histogram collection performance by sampling
Histogram collection is done by sampling a percentage of rows from the table,
not looking at all individual ones.
The default implementation, to keep the server's Engine Indepenent
Statistics component working uses Bernoulli sampling. It does a simple
table scan, but only accepts rows that pass a dice roll. This
implementation is done as a storage engine interface method, so as to
allow faster and/or more efficient implementations for storage engines
internally.
The number of rows collected is capped to a minimum of 50000 and
increases logarithmically with a coffecient of 4096. The coffecient is
chosen so that we expect an error of less than 3% in our estimations
according to the paper:
"Random Sampling for Histogram Construction: How much is enough?”
– Surajit Chaudhuri, Rajeev Motwani, Vivek Narasayya, ACM SIGMOD, 1998.
This interface is also a precursor to allowing SELECT ... FROM table
with sampling to work.
Performance wise, for a table of 10 million rows and 13 columns, 6 int,
6 doubles, one string, the previous analyze table statistics took
1 minute 20 seconds to collect all data. Post implementation, the
time is less than 6 seconds. This was run on an InnoDB table, NVME SSD with
approximately 2GB/s read speed and 500MB/s write speed.
---
mysql-test/main/selectivity.result | 8 +++----
mysql-test/main/selectivity_innodb.result | 8 +++----
sql/handler.cc | 14 +++++++++++
sql/handler.h | 40 ++++++++++++++++++++++++++++++-
sql/sql_statistics.cc | 32 +++++++++++++++++++------
5 files changed, 86 insertions(+), 16 deletions(-)
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index 00907235ecc..6d09c1c9b62 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -1290,9 +1290,9 @@ explain extended
select * from t1, t2, t1 as t3
where t1.b=t2.c and t2.d=t3.a and t3.b<5 and t1.a < 2000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 262144 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 262117 100.00 Using where
1 SIMPLE t2 ref c,d c 5 test.t1.b 5 100.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 262144 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 262117 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t3` where `test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`a` = `test`.`t2`.`d` and `test`.`t3`.`b` < 5 and `test`.`t1`.`a` < 2000
select * from t1, t2, t1 as t3
@@ -1307,9 +1307,9 @@ explain extended
select * from t1, t2, t1 as t3
where t1.b=t2.c and t2.d=t3.a and t3.b<5 and t1.a < 2000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 262144 0.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 262117 0.00 Using where
1 SIMPLE t2 ref c,d d 5 test.t3.a 7 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 262144 2.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 262117 2.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t3` where `test`.`t1`.`b` = `test`.`t2`.`c` and `test`.`t2`.`d` = `test`.`t3`.`a` and `test`.`t3`.`b` < 5 and `test`.`t1`.`a` < 2000
select * from t1, t2, t1 as t3
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index 93917065722..0b20a40f69f 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -1300,9 +1300,9 @@ explain extended
select * from t1, t2, t1 as t3
where t1.b=t2.c and t2.d=t3.a and t3.b<5 and t1.a < 2000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1 ALL NULL NULL NULL NULL 262144 100.00 Using where
+1 SIMPLE t1 ALL NULL NULL NULL NULL 262117 100.00 Using where
1 SIMPLE t2 ref c,d c 5 test.t1.b 5 100.00
-1 SIMPLE t3 ALL NULL NULL NULL NULL 262144 100.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t3 ALL NULL NULL NULL NULL 262117 100.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t3` where `test`.`t2`.`c` = `test`.`t1`.`b` and `test`.`t3`.`a` = `test`.`t2`.`d` and `test`.`t3`.`b` < 5 and `test`.`t1`.`a` < 2000
select * from t1, t2, t1 as t3
@@ -1317,9 +1317,9 @@ explain extended
select * from t1, t2, t1 as t3
where t1.b=t2.c and t2.d=t3.a and t3.b<5 and t1.a < 2000;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 ALL NULL NULL NULL NULL 262144 0.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 262117 0.00 Using where
1 SIMPLE t2 ref c,d d 5 test.t3.a 7 100.00
-1 SIMPLE t1 ALL NULL NULL NULL NULL 262144 2.00 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t1 ALL NULL NULL NULL NULL 262117 2.00 Using where; Using join buffer (flat, BNL join)
Warnings:
Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t2`.`d` AS `d`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` join `test`.`t2` join `test`.`t1` `t3` where `test`.`t1`.`b` = `test`.`t2`.`c` and `test`.`t2`.`d` = `test`.`t3`.`a` and `test`.`t3`.`b` < 5 and `test`.`t1`.`a` < 2000
select * from t1, t2, t1 as t3
diff --git a/sql/handler.cc b/sql/handler.cc
index 2e45b5883ea..16fb126918e 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -7547,3 +7547,17 @@ bool Vers_parse_info::check_sys_fields(const Lex_table_name &table_name,
"ROW END" : found_flag ? "ROW START" : "ROW START/END");
return true;
}
+
+int handler::random_sample(uchar *buf)
+{
+ int rc;
+ THD *thd= ha_thd();
+ do
+ {
+ if (table->in_use->check_killed(1))
+ return HA_ERR_ABORTED_BY_USER;
+ rc= rnd_next(buf);
+ } while (rc == HA_ERR_RECORD_DELETED || thd_rnd(thd) > sample_fraction);
+
+ return rc;
+}
diff --git a/sql/handler.h b/sql/handler.h
index dfb2333b24e..fcdadbeb42b 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1913,6 +1913,11 @@ enum enum_stats_auto_recalc { HA_STATS_AUTO_RECALC_DEFAULT= 0,
HA_STATS_AUTO_RECALC_ON,
HA_STATS_AUTO_RECALC_OFF };
+enum sample_mode {
+ HA_SAMPLE_BERNOULLI= 0,
+ HA_SAMPLE_SYSTEM
+};
+
/**
A helper struct for schema DDL statements:
CREATE SCHEMA [IF NOT EXISTS] name [ schema_specification... ]
@@ -2947,9 +2952,11 @@ class handler :public Sql_alloc
/** Length of ref (1-8 or the clustered key length) */
uint ref_length;
FT_INFO *ft_handler;
- enum init_stat { NONE=0, INDEX, RND };
+ enum init_stat { NONE=0, INDEX, RND, SAMPLE };
init_stat inited, pre_inited;
+ double sample_fraction= 0;
+ enum sample_mode sample_mode;
const COND *pushed_cond;
/**
next_insert_id is the next value which should be inserted into the
@@ -3112,6 +3119,31 @@ class handler :public Sql_alloc
virtual int prepare_range_scan(const key_range *start_key, const key_range *end_key)
{ return 0; }
+ int ha_random_sample_init(THD *thd, enum sample_mode mode, double fraction)
+ __attribute__((warn_unused_result))
+ {
+ DBUG_ENTER("ha_random_sample_init");
+ DBUG_ASSERT(inited==NONE);
+ int result;
+ sample_mode= mode;
+ sample_fraction= fraction;
+ inited= (result= random_sample_init(mode, fraction)) ? NONE : SAMPLE;
+ DBUG_RETURN(result);
+ }
+ int ha_random_sample(uchar *buf)
+ __attribute__((warn_unused_result))
+ {
+ DBUG_ENTER("ha_random_sample");
+ DBUG_ASSERT(inited == SAMPLE);
+ DBUG_RETURN(random_sample(buf));
+ }
+ int ha_random_sample_end()
+ {
+ DBUG_ENTER("ha_random_sample_end");
+ inited= NONE;
+ DBUG_RETURN(random_sample_end());
+ }
+
int ha_rnd_init(bool scan) __attribute__ ((warn_unused_result))
{
DBUG_EXECUTE_IF("ha_rnd_init_fail", return HA_ERR_TABLE_DEF_CHANGED;);
@@ -4425,6 +4457,12 @@ class handler :public Sql_alloc
/* Note: ha_index_read_idx_map() may bypass index_init() */
virtual int index_init(uint idx, bool sorted) { return 0; }
virtual int index_end() { return 0; }
+ virtual int random_sample_init(enum sample_mode mode, double fraction)
+ {
+ return rnd_init(TRUE);
+ }
+ virtual int random_sample(uchar *buf);
+ virtual int random_sample_end() { return rnd_end(); }
/**
rnd_init() can be called two times without rnd_end() in between
(it only makes sense if scan=1).
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index db214a1fe28..22a015821de 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2727,12 +2727,16 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
Field *table_field;
ha_rows rows= 0;
handler *file=table->file;
+ double sample_fraction;
+ const ha_rows MIN_THRESHOLD_FOR_SAMPLING= 50000;
DBUG_ENTER("collect_statistics_for_table");
table->collected_stats->cardinality_is_null= TRUE;
table->collected_stats->cardinality= 0;
+ table->file->info(HA_STATUS_VARIABLE);
+
for (field_ptr= table->field; *field_ptr; field_ptr++)
{
table_field= *field_ptr;
@@ -2743,12 +2747,27 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
restore_record(table, s->default_values);
- /* Perform a full table scan to collect statistics on 'table's columns */
- if (!(rc= file->ha_rnd_init(TRUE)))
- {
+
+ if (file->records() < MIN_THRESHOLD_FOR_SAMPLING)
+ {
+ sample_fraction= 1;
+ }
+ else
+ {
+ sample_fraction= std::fmin(
+ (MIN_THRESHOLD_FOR_SAMPLING + 4096 *
+ log(200 * file->records())) / file->records(), 1);
+ }
+
+
+ /* Fetch samples from the table to collect statistics on table's columns */
+
+ if (!(rc= file->ha_random_sample_init(thd, HA_SAMPLE_BERNOULLI,
+ sample_fraction)))
+ {
DEBUG_SYNC(table->in_use, "statistics_collection_start");
- while ((rc= file->ha_rnd_next(table->record[0])) != HA_ERR_END_OF_FILE)
+ while ((rc= file->ha_random_sample(table->record[0])) != HA_ERR_END_OF_FILE)
{
if (thd->killed)
break;
@@ -2768,10 +2787,9 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
break;
rows++;
}
- file->ha_rnd_end();
+ file->ha_random_sample_end();
}
rc= (rc == HA_ERR_END_OF_FILE && !thd->killed) ? 0 : 1;
-
/*
Calculate values for all statistical characteristics on columns and
and for each field f of 'table' save them in the write_stat structure
@@ -2780,7 +2798,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
if (!rc)
{
table->collected_stats->cardinality_is_null= FALSE;
- table->collected_stats->cardinality= rows;
+ table->collected_stats->cardinality= rows / sample_fraction;
}
bitmap_clear_all(table->write_set);
1
0
[Commits] d11be23: MDEV-17096 Pushdown of simple derived tables to storage engines
by IgorBabaev 10 Feb '19
by IgorBabaev 10 Feb '19
10 Feb '19
revision-id: d11be23933def394585fae83a6f1ab561e3736f2 (mariadb-10.3.6-132-gd11be23)
parent(s): 3f9040085a0de4976f55bc7e4a2fa5fa8d923100
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-09 22:54:26 -0800
message:
MDEV-17096 Pushdown of simple derived tables to storage engines
Resolved the problem of forming a proper query string for FEDERATEDX.
Added test cases.
Cleanup of extra spaces.
---
.../federated/federatedx_create_handlers.result | 119 +++++++++++++++++++--
.../federated/federatedx_create_handlers.test | 60 +++++++++--
sql/derived_handler.cc | 8 +-
sql/item_cmpfunc.cc | 9 +-
sql/item_subselect.cc | 6 +-
sql/mysqld.h | 2 +
sql/select_handler.cc | 14 +--
sql/select_handler.h | 10 +-
sql/sql_derived.cc | 34 ++++--
sql/sql_explain.cc | 6 +-
sql/sql_select.cc | 8 +-
sql/table.h | 1 +
storage/federatedx/federatedx_pushdown.cc | 19 ++--
storage/federatedx/federatedx_pushdown.h | 4 +-
14 files changed, 233 insertions(+), 67 deletions(-)
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result
index fdad44c..a25b019 100644
--- a/mysql-test/suite/federated/federatedx_create_handlers.result
+++ b/mysql-test/suite/federated/federatedx_create_handlers.result
@@ -10,7 +10,7 @@ Warnings:
Note 1051 Unknown table 'federated.t1'
CREATE TABLE federated.t1 (
id int(20) NOT NULL,
-name varchar(16) NOT NULL default ''
+name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
INSERT INTO federated.t1 VALUES
@@ -19,7 +19,7 @@ DROP TABLE IF EXISTS federated.t2;
Warnings:
Note 1051 Unknown table 'federated.t2'
CREATE TABLE federated.t2 (
-name varchar(16) NOT NULL default ''
+name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
INSERT INTO federated.t2 VALUES
@@ -30,7 +30,7 @@ Warnings:
Note 1051 Unknown table 'federated.t1'
CREATE TABLE federated.t1 (
id int(20) NOT NULL,
-name varchar(16) NOT NULL default ''
+name varchar(16) NOT NULL default ''
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1';
@@ -38,7 +38,7 @@ DROP TABLE IF EXISTS federated.t2;
Warnings:
Note 1051 Unknown table 'federated.t2'
CREATE TABLE federated.t2 (
-name varchar(16) NOT NULL default ''
+name varchar(16) NOT NULL default ''
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t2';
@@ -123,7 +123,7 @@ ANALYZE
}
}
CREATE TABLE federated.t3 (
-name varchar(16) NOT NULL default ''
+name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
INSERT INTO federated.t3 VALUES
@@ -190,7 +190,114 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 7.00 100.00 100.00
1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 0.00 100.00 100.00
2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
-DROP TABLE federated.t1, federated.t2;
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+name name
+xxx xxx
+EXPLAIN
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 7
+1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2
+2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL
+3 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 Using temporary
+ANALYZE FORMAT=JSON
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "t3",
+ "access_type": "ALL",
+ "r_loops": 1,
+ "rows": 7,
+ "r_rows": 7,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "18",
+ "used_key_parts": ["name"],
+ "ref": ["federated.t3.name"],
+ "r_loops": 7,
+ "rows": 2,
+ "r_rows": 0,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "message": "Pushed derived"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "r_loops": 0,
+ "rows": 7,
+ "r_rows": null,
+ "filtered": 100,
+ "r_filtered": null
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+}
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+( SELECT * FROM federated.t1 WHERE id < 3
+UNION
+SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+id name
+5 yyy
+7 yyy
+5 yyy
+7 yyy
+5 yyy
+7 yyy
+EXPLAIN
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+( SELECT * FROM federated.t1 WHERE id < 3
+UNION
+SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 7
+1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2
+2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE federated.t1, federated.t2, federated.t3;
connection slave;
DROP TABLE federated.t1, federated.t2;
connection default;
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test
index 0e586da..21539b6 100644
--- a/mysql-test/suite/federated/federatedx_create_handlers.test
+++ b/mysql-test/suite/federated/federatedx_create_handlers.test
@@ -7,7 +7,7 @@ DROP TABLE IF EXISTS federated.t1;
CREATE TABLE federated.t1 (
id int(20) NOT NULL,
- name varchar(16) NOT NULL default ''
+ name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
@@ -17,7 +17,7 @@ INSERT INTO federated.t1 VALUES
DROP TABLE IF EXISTS federated.t2;
CREATE TABLE federated.t2 (
- name varchar(16) NOT NULL default ''
+ name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
@@ -33,7 +33,7 @@ DROP TABLE IF EXISTS federated.t1;
eval
CREATE TABLE federated.t1 (
id int(20) NOT NULL,
- name varchar(16) NOT NULL default ''
+ name varchar(16) NOT NULL default ''
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1';
@@ -43,7 +43,7 @@ DROP TABLE IF EXISTS federated.t2;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval
CREATE TABLE federated.t2 (
- name varchar(16) NOT NULL default ''
+ name varchar(16) NOT NULL default ''
)
ENGINE="FEDERATED" DEFAULT CHARSET=latin1
CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2';
@@ -76,11 +76,12 @@ SELECT id FROM federated.t1 WHERE id < 5;
ANALYZE
SELECT id FROM federated.t1 WHERE id < 5;
+--source include/analyze-format.inc
ANALYZE FORMAT=JSON
SELECT id FROM federated.t1 WHERE id < 5;
CREATE TABLE federated.t3 (
- name varchar(16) NOT NULL default ''
+ name varchar(16) NOT NULL default ''
)
DEFAULT CHARSET=latin1;
@@ -89,26 +90,63 @@ INSERT INTO federated.t3 VALUES
SELECT *
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
-WHERE federated.t3.name=t.name;
+WHERE federated.t3.name=t.name;
EXPLAIN
SELECT *
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
-WHERE federated.t3.name=t.name;
+WHERE federated.t3.name=t.name;
EXPLAIN FORMAT=JSON
SELECT *
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
-WHERE federated.t3.name=t.name;
+WHERE federated.t3.name=t.name;
ANALYZE
SELECT *
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
-WHERE federated.t3.name=t.name;
+WHERE federated.t3.name=t.name;
-DROP TABLE federated.t1, federated.t2;
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
-connection slave;
+EXPLAIN
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+
+--source include/analyze-format.inc
+ANALYZE FORMAT=JSON
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+ ( SELECT * FROM federated.t1 WHERE id < 3
+ UNION
+ SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+
+EXPLAIN
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+ ( SELECT * FROM federated.t1 WHERE id < 3
+ UNION
+ SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+
+
+DROP TABLE federated.t1, federated.t2, federated.t3;
+
+connection slave;
DROP TABLE federated.t1, federated.t2;
connection default;
diff --git a/sql/derived_handler.cc b/sql/derived_handler.cc
index 561c18a..1fa5e94 100644
--- a/sql/derived_handler.cc
+++ b/sql/derived_handler.cc
@@ -16,7 +16,7 @@ void derived_handler::set_derived(TABLE_LIST *tbl)
Pushdown_derived::Pushdown_derived(TABLE_LIST *tbl, derived_handler *h)
: derived(tbl), handler(h)
-{
+{
is_analyze= handler->thd->lex->analyze_stmt;
}
@@ -42,7 +42,7 @@ int Pushdown_derived::execute()
handler->end_scan();
DBUG_RETURN(0);
}
-
+
while (!(err= handler->next_row()))
{
if (unlikely(thd->check_killed()))
@@ -50,7 +50,7 @@ int Pushdown_derived::execute()
handler->end_scan();
DBUG_RETURN(-1);
}
-
+
if ((err= table->file->ha_write_tmp_row(table->record[0])))
{
bool is_duplicate;
@@ -81,4 +81,4 @@ int Pushdown_derived::execute()
handler->print_error(err, MYF(0));
DBUG_RETURN(-1); // Error not sent to client
}
-
+
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 4cd6304..821f51f 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1215,8 +1215,13 @@ bool Item_in_optimizer::eval_not_null_tables(void *opt_arg)
void Item_in_optimizer::print(String *str, enum_query_type query_type)
{
- restore_first_argument();
- Item_func::print(str, query_type);
+ if (query_type & QT_PARSABLE)
+ args[1]->print(str, query_type);
+ else
+ {
+ restore_first_argument();
+ Item_func::print(str, query_type);
+ }
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 0ace59f..7aa2ed4 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3272,7 +3272,8 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
void Item_in_subselect::print(String *str, enum_query_type query_type)
{
- if (test_strategy(SUBS_IN_TO_EXISTS))
+ if (test_strategy(SUBS_IN_TO_EXISTS) &&
+ !(query_type & QT_PARSABLE))
str->append(STRING_WITH_LEN("<exists>"));
else
{
@@ -3499,7 +3500,8 @@ Item_allany_subselect::select_transformer(JOIN *join)
void Item_allany_subselect::print(String *str, enum_query_type query_type)
{
- if (test_strategy(SUBS_IN_TO_EXISTS))
+ if (test_strategy(SUBS_IN_TO_EXISTS) &&
+ !(query_type & QT_PARSABLE))
str->append(STRING_WITH_LEN("<exists>"));
else
{
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 3d056fb..320dedc 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -745,6 +745,8 @@ enum enum_query_type
/// SHOW CREATE {VIEW|PROCEDURE|FUNCTION} and other cases where the
/// original representation is required, should set this flag.
QT_ITEM_ORIGINAL_FUNC_NULLIF= (1 << 7),
+ /// good for parsing
+ QT_PARSABLE= (1 << 8),
/// This value means focus on readability, not on ability to parse back, etc.
QT_EXPLAIN= QT_TO_SYSTEM_CHARSET |
diff --git a/sql/select_handler.cc b/sql/select_handler.cc
index 17475f4..9a8d391 100644
--- a/sql/select_handler.cc
+++ b/sql/select_handler.cc
@@ -6,7 +6,7 @@
Pushdown_select::Pushdown_select(SELECT_LEX *sel, select_handler *h)
: select(sel), handler(h)
-{
+{
is_analyze= handler->thd->lex->analyze_stmt;
}
@@ -35,7 +35,7 @@ bool Pushdown_select::init()
DBUG_RETURN(true);
if (handler->table->fill_item_list(&result_columns))
DBUG_RETURN(true);
- DBUG_RETURN(false);
+ DBUG_RETURN(false);
}
bool Pushdown_select::send_result_set_metadata()
@@ -74,7 +74,7 @@ bool Pushdown_select::send_data()
protocol->remove_last_row();
DBUG_RETURN(true);
}
-
+
thd->inc_sent_row_count(1);
if (thd->vio_ok())
@@ -88,13 +88,13 @@ bool Pushdown_select::send_eof()
THD *thd= handler->thd;
DBUG_ENTER("Pushdown_select::send_eof");
- /*
+ /*
Don't send EOF if we're in error condition (which implies we've already
sent or are sending an error)
*/
if (thd->is_error())
DBUG_RETURN(true);
- ::my_eof(thd);
+ ::my_eof(thd);
DBUG_RETURN(false);
}
@@ -113,10 +113,10 @@ int Pushdown_select::execute()
handler->end_scan();
DBUG_RETURN(0);
}
-
+
if (send_result_set_metadata())
DBUG_RETURN(-1);
-
+
while (!(err= handler->next_row()))
{
if (thd->check_killed() || send_data())
diff --git a/sql/select_handler.h b/sql/select_handler.h
index 3b1347e..19a1883 100644
--- a/sql/select_handler.h
+++ b/sql/select_handler.h
@@ -20,9 +20,9 @@ class select_handler
select_handler(THD *thd_arg, handlerton *ht_arg)
: thd(thd_arg), ht(ht_arg), table(0) {}
-
- virtual ~select_handler() {}
-
+
+ virtual ~select_handler() {}
+
/*
Functions to scan the select result set.
All these returns 0 if ok, error code in case of error.
@@ -32,7 +32,7 @@ class select_handler
virtual int init_scan() = 0;
/*
- Put the next produced row of the result set in table->record[0]
+ Put the next produced row of the result set in table->record[0]
and return 0. Return HA_ERR_END_OF_FILE if there are no more rows,
return other error number in case of fatal error.
*/
@@ -40,7 +40,7 @@ class select_handler
/* Finish scanning */
virtual int end_scan() = 0;
-
+
/* Report errors */
virtual void print_error(int error, myf errflag) = 0;
};
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 9ad22dd..564049e 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -385,7 +385,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_RETURN(FALSE);
}
- if ((derived->dt_handler= derived->find_derived_handler(thd)))
+ if (derived->dt_handler)
{
derived->change_refs_to_fields();
derived->set_materialized_derived();
@@ -820,6 +820,24 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
if (derived->is_derived() && derived->is_merged_derived())
first_select->mark_as_belong_to_derived(derived);
+ derived->dt_handler= derived->find_derived_handler(thd);
+ if (derived->dt_handler)
+ {
+ char query_buff[4096];
+ String derived_query(query_buff, sizeof(query_buff), thd->charset());
+ derived_query.length(0);
+ derived->derived->print(&derived_query,
+ enum_query_type(QT_VIEW_INTERNAL |
+ QT_ITEM_ORIGINAL_FUNC_NULLIF |
+ QT_PARSABLE));
+ if (!thd->make_lex_string(&derived->derived_spec,
+ derived_query.ptr(), derived_query.length()))
+ {
+ delete derived->dt_handler;
+ derived->dt_handler= NULL;
+ }
+ }
+
exit:
/* Hide "Unknown column" or "Unknown function" error */
if (derived->view)
@@ -912,19 +930,17 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_RETURN(FALSE);
}
- if (derived->is_materialized_derived() && !derived->dt_handler)
- derived->dt_handler= derived->find_derived_handler(thd);
- if (derived->dt_handler)
+ if (derived->is_materialized_derived() && derived->dt_handler)
{
if (!(derived->pushdown_derived=
new (thd->mem_root) Pushdown_derived(derived, derived->dt_handler)))
{
delete derived->dt_handler;
- derived->dt_handler= NULL;
- DBUG_RETURN(1);
+ derived->dt_handler= NULL;
+ DBUG_RETURN(TRUE);
}
- }
-
+ }
+
lex->current_select= first_select;
if (unit->is_unit_op())
@@ -1136,7 +1152,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived)
if (unit->executed)
DBUG_RETURN(FALSE);
res= derived->pushdown_derived->execute();
- unit->executed= true;
+ unit->executed= true;
delete derived->pushdown_derived;
DBUG_RETURN(res);
}
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index b8d80c7..7bb04fe 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -339,7 +339,7 @@ int print_explain_row(select_result_sink *result,
if (!select_type[0])
return 0;
-
+
item_list.push_back(new (mem_root) Item_int(thd, (int32) select_number),
mem_root);
item_list.push_back(new (mem_root) Item_string_sys(thd, select_type),
@@ -756,7 +756,7 @@ int Explain_select::print_explain(Explain_query *query,
{
print_explain_message_line(output, explain_flags, is_analyze,
select_id /*select number*/,
- select_type,
+ select_type,
NULL, /* rows */
NULL);
}
@@ -1225,7 +1225,7 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
{
THD *thd= output->thd;
MEM_ROOT *mem_root= thd->mem_root;
-
+
List<Item> item_list;
Item *item_null= new (mem_root) Item_null(thd);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 7cbbdfe..e9040e1 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -4044,7 +4044,7 @@ void JOIN::exec_inner()
not the case.
*/
if (exec_const_order_group_cond.elements &&
- !(select_options & SELECT_DESCRIBE) &&
+ !(select_options & SELECT_DESCRIBE) &&
!select_lex->pushdown_select)
{
List_iterator_fast<Item> const_item_it(exec_const_order_group_cond);
@@ -4300,7 +4300,7 @@ mysql_select(THD *thd,
DBUG_RETURN(TRUE);
}
}
-
+
if ((err= join->optimize()))
{
goto err; // 1
@@ -4322,7 +4322,7 @@ mysql_select(THD *thd,
select_lex->where= join->conds_history;
select_lex->having= join->having_history;
}
-
+
err:
if (select_lex->pushdown_select)
@@ -25885,7 +25885,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
res= unit->exec();
}
}
- else
+ else
{
thd->lex->current_select= first;
unit->set_limit(unit->global_parameters());
diff --git a/sql/table.h b/sql/table.h
index 7b88344..f7bcdaa 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2137,6 +2137,7 @@ struct TABLE_LIST
bool is_derived_with_recursive_reference;
bool block_handle_derived;
derived_handler *dt_handler;
+ LEX_CSTRING derived_spec;
Pushdown_derived *pushdown_derived;
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex;
diff --git a/storage/federatedx/federatedx_pushdown.cc b/storage/federatedx/federatedx_pushdown.cc
index bfe421c..c53b359 100644
--- a/storage/federatedx/federatedx_pushdown.cc
+++ b/storage/federatedx/federatedx_pushdown.cc
@@ -38,14 +38,14 @@ create_federatedx_derived_handler(THD* thd, TABLE_LIST *derived)
return 0;
}
}
-
+
handler= new ha_federatedx_derived_handler(thd, derived);
return handler;
}
-/*
+/*
Implementation class of the derived_handler interface for FEDERATEDX:
class implementation
*/
@@ -62,7 +62,6 @@ ha_federatedx_derived_handler::~ha_federatedx_derived_handler() {}
int ha_federatedx_derived_handler::init_scan()
{
- char query_buff[4096];
THD *thd;
int rc= 0;
@@ -76,12 +75,8 @@ int ha_federatedx_derived_handler::init_scan()
txn= h->get_txn(thd);
if ((rc= txn->acquire(share, thd, TRUE, iop)))
DBUG_RETURN(rc);
-
- String derived_query(query_buff, sizeof(query_buff), thd->charset());
- derived_query.length(0);
- derived->derived->print(&derived_query, QT_ORDINARY);
-
- if ((*iop)->query(derived_query.ptr(), derived_query.length()))
+
+ if ((*iop)->query(derived->derived_spec.str, derived->derived_spec.length))
goto err;
stored_result= (*iop)->store_result();
@@ -93,7 +88,7 @@ int ha_federatedx_derived_handler::init_scan()
err:
DBUG_RETURN(HA_FEDERATEDX_ERROR_WITH_REMOTE_SYSTEM);
}
-
+
int ha_federatedx_derived_handler::next_row()
{
int rc;
@@ -167,7 +162,7 @@ create_federatedx_select_handler(THD* thd, SELECT_LEX *sel)
return handler;
}
-/*
+/*
Implementation class of the select_handler interface for FEDERATEDX:
class implementation
*/
@@ -175,7 +170,7 @@ create_federatedx_select_handler(THD* thd, SELECT_LEX *sel)
ha_federatedx_select_handler::ha_federatedx_select_handler(THD *thd,
SELECT_LEX *sel)
: select_handler(thd, federatedx_hton),
- share(NULL), txn(NULL), iop(NULL), stored_result(NULL)
+ share(NULL), txn(NULL), iop(NULL), stored_result(NULL)
{
select= sel;
}
diff --git a/storage/federatedx/federatedx_pushdown.h b/storage/federatedx/federatedx_pushdown.h
index 961571b..673abcf 100644
--- a/storage/federatedx/federatedx_pushdown.h
+++ b/storage/federatedx/federatedx_pushdown.h
@@ -17,7 +17,7 @@
#include "derived_handler.h"
#include "select_handler.h"
-/*
+/*
Implementation class of the derived_handler interface for FEDERATEDX:
class declaration
*/
@@ -40,7 +40,7 @@ class ha_federatedx_derived_handler: public derived_handler
};
-/*
+/*
Implementation class of the select_handler interface for FEDERATEDX:
class declaration
*/
1
0
[Commits] 7ac24ca: MDEV-17096 Pushdown of simple derived tables to storage engines
by IgorBabaev 10 Feb '19
by IgorBabaev 10 Feb '19
10 Feb '19
revision-id: 7ac24cafb339fbd2180859db11888fa5e465b1c4 (mariadb-10.3.6-132-g7ac24ca)
parent(s): 3f9040085a0de4976f55bc7e4a2fa5fa8d923100
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-09 20:59:03 -0800
message:
MDEV-17096 Pushdown of simple derived tables to storage engines
Resolved the problem of forming a proper query string for FEDERATEDX.
Added test cases.
---
.../federated/federatedx_create_handlers.result | 109 ++++++++++++++++++++-
.../federated/federatedx_create_handlers.test | 40 +++++++-
sql/item_cmpfunc.cc | 9 +-
sql/item_subselect.cc | 6 +-
sql/mysqld.h | 2 +
sql/sql_derived.cc | 26 ++++-
sql/table.h | 1 +
storage/federatedx/federatedx_pushdown.cc | 7 +-
8 files changed, 183 insertions(+), 17 deletions(-)
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result
index fdad44c..937e2b6 100644
--- a/mysql-test/suite/federated/federatedx_create_handlers.result
+++ b/mysql-test/suite/federated/federatedx_create_handlers.result
@@ -190,7 +190,114 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 PRIMARY t3 ALL NULL NULL NULL NULL 7 7.00 100.00 100.00
1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2 0.00 100.00 100.00
2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL
-DROP TABLE federated.t1, federated.t2;
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+name name
+xxx xxx
+EXPLAIN
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 7
+1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2
+2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL
+3 MATERIALIZED t2 ALL NULL NULL NULL NULL 7 Using temporary
+ANALYZE FORMAT=JSON
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+WHERE id IN (SELECT count(*)
+FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+ANALYZE
+{
+ "query_block": {
+ "select_id": 1,
+ "r_loops": 1,
+ "r_total_time_ms": "REPLACED",
+ "table": {
+ "table_name": "t3",
+ "access_type": "ALL",
+ "r_loops": 1,
+ "rows": 7,
+ "r_rows": 7,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "18",
+ "used_key_parts": ["name"],
+ "ref": ["federated.t3.name"],
+ "r_loops": 7,
+ "rows": 2,
+ "r_rows": 0,
+ "r_total_time_ms": "REPLACED",
+ "filtered": 100,
+ "r_filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "message": "Pushed derived"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "r_loops": 0,
+ "rows": 7,
+ "r_rows": null,
+ "filtered": 100,
+ "r_filtered": null
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+}
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+( SELECT * FROM federated.t1 WHERE id < 3
+UNION
+SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+id name
+5 yyy
+7 yyy
+5 yyy
+7 yyy
+5 yyy
+7 yyy
+EXPLAIN
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+( SELECT * FROM federated.t1 WHERE id < 3
+UNION
+SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 7
+1 PRIMARY <derived2> ref key0 key0 18 federated.t3.name 2
+2 PUSHED DERIVED NULL NULL NULL NULL NULL NULL NULL NULL
+DROP TABLE federated.t1, federated.t2, federated.t3;
connection slave;
DROP TABLE federated.t1, federated.t2;
connection default;
diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test
index 0e586da..6577943 100644
--- a/mysql-test/suite/federated/federatedx_create_handlers.test
+++ b/mysql-test/suite/federated/federatedx_create_handlers.test
@@ -76,6 +76,7 @@ SELECT id FROM federated.t1 WHERE id < 5;
ANALYZE
SELECT id FROM federated.t1 WHERE id < 5;
+--source include/analyze-format.inc
ANALYZE FORMAT=JSON
SELECT id FROM federated.t1 WHERE id < 5;
@@ -106,7 +107,44 @@ SELECT *
FROM federated.t3, (SELECT * FROM federated.t1 WHERE id > 3) t
WHERE federated.t3.name=t.name;
-DROP TABLE federated.t1, federated.t2;
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+
+EXPLAIN
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+
+--source include/analyze-format.inc
+ANALYZE FORMAT=JSON
+SELECT *
+FROM federated.t3, (SELECT t1.name FROM federated.t1
+ WHERE id IN (SELECT count(*)
+ FROM federated.t2 GROUP BY name)) t
+WHERE federated.t3.name=t.name;
+
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+ ( SELECT * FROM federated.t1 WHERE id < 3
+ UNION
+ SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+
+EXPLAIN
+SELECT t.id, federated.t3.name
+FROM federated.t3,
+ ( SELECT * FROM federated.t1 WHERE id < 3
+ UNION
+ SELECT * FROM federated.t1 WHERE id >= 5) t
+WHERE federated.t3.name=t.name;
+
+
+DROP TABLE federated.t1, federated.t2, federated.t3;
connection slave;
DROP TABLE federated.t1, federated.t2;
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 4cd6304..821f51f 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1215,8 +1215,13 @@ bool Item_in_optimizer::eval_not_null_tables(void *opt_arg)
void Item_in_optimizer::print(String *str, enum_query_type query_type)
{
- restore_first_argument();
- Item_func::print(str, query_type);
+ if (query_type & QT_PARSABLE)
+ args[1]->print(str, query_type);
+ else
+ {
+ restore_first_argument();
+ Item_func::print(str, query_type);
+ }
}
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 0ace59f..7aa2ed4 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -3272,7 +3272,8 @@ Item_in_subselect::select_in_like_transformer(JOIN *join)
void Item_in_subselect::print(String *str, enum_query_type query_type)
{
- if (test_strategy(SUBS_IN_TO_EXISTS))
+ if (test_strategy(SUBS_IN_TO_EXISTS) &&
+ !(query_type & QT_PARSABLE))
str->append(STRING_WITH_LEN("<exists>"));
else
{
@@ -3499,7 +3500,8 @@ Item_allany_subselect::select_transformer(JOIN *join)
void Item_allany_subselect::print(String *str, enum_query_type query_type)
{
- if (test_strategy(SUBS_IN_TO_EXISTS))
+ if (test_strategy(SUBS_IN_TO_EXISTS) &&
+ !(query_type & QT_PARSABLE))
str->append(STRING_WITH_LEN("<exists>"));
else
{
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 3d056fb..320dedc 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -745,6 +745,8 @@ enum enum_query_type
/// SHOW CREATE {VIEW|PROCEDURE|FUNCTION} and other cases where the
/// original representation is required, should set this flag.
QT_ITEM_ORIGINAL_FUNC_NULLIF= (1 << 7),
+ /// good for parsing
+ QT_PARSABLE= (1 << 8),
/// This value means focus on readability, not on ability to parse back, etc.
QT_EXPLAIN= QT_TO_SYSTEM_CHARSET |
diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc
index 9ad22dd..00ecb2c 100644
--- a/sql/sql_derived.cc
+++ b/sql/sql_derived.cc
@@ -385,7 +385,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_RETURN(FALSE);
}
- if ((derived->dt_handler= derived->find_derived_handler(thd)))
+ if (derived->dt_handler)
{
derived->change_refs_to_fields();
derived->set_materialized_derived();
@@ -820,6 +820,24 @@ bool mysql_derived_prepare(THD *thd, LEX *lex, TABLE_LIST *derived)
if (derived->is_derived() && derived->is_merged_derived())
first_select->mark_as_belong_to_derived(derived);
+ derived->dt_handler= derived->find_derived_handler(thd);
+ if (derived->dt_handler)
+ {
+ char query_buff[4096];
+ String derived_query(query_buff, sizeof(query_buff), thd->charset());
+ derived_query.length(0);
+ derived->derived->print(&derived_query,
+ enum_query_type(QT_VIEW_INTERNAL |
+ QT_ITEM_ORIGINAL_FUNC_NULLIF |
+ QT_PARSABLE));
+ if (!thd->make_lex_string(&derived->derived_spec,
+ derived_query.ptr(), derived_query.length()))
+ {
+ delete derived->dt_handler;
+ derived->dt_handler= NULL;
+ }
+ }
+
exit:
/* Hide "Unknown column" or "Unknown function" error */
if (derived->view)
@@ -912,16 +930,14 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived)
DBUG_RETURN(FALSE);
}
- if (derived->is_materialized_derived() && !derived->dt_handler)
- derived->dt_handler= derived->find_derived_handler(thd);
- if (derived->dt_handler)
+ if (derived->is_materialized_derived() && derived->dt_handler)
{
if (!(derived->pushdown_derived=
new (thd->mem_root) Pushdown_derived(derived, derived->dt_handler)))
{
delete derived->dt_handler;
derived->dt_handler= NULL;
- DBUG_RETURN(1);
+ DBUG_RETURN(TRUE);
}
}
diff --git a/sql/table.h b/sql/table.h
index 7b88344..f7bcdaa 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -2137,6 +2137,7 @@ struct TABLE_LIST
bool is_derived_with_recursive_reference;
bool block_handle_derived;
derived_handler *dt_handler;
+ LEX_CSTRING derived_spec;
Pushdown_derived *pushdown_derived;
ST_SCHEMA_TABLE *schema_table; /* Information_schema table */
st_select_lex *schema_select_lex;
diff --git a/storage/federatedx/federatedx_pushdown.cc b/storage/federatedx/federatedx_pushdown.cc
index bfe421c..bae69d4 100644
--- a/storage/federatedx/federatedx_pushdown.cc
+++ b/storage/federatedx/federatedx_pushdown.cc
@@ -62,7 +62,6 @@ ha_federatedx_derived_handler::~ha_federatedx_derived_handler() {}
int ha_federatedx_derived_handler::init_scan()
{
- char query_buff[4096];
THD *thd;
int rc= 0;
@@ -77,11 +76,7 @@ int ha_federatedx_derived_handler::init_scan()
if ((rc= txn->acquire(share, thd, TRUE, iop)))
DBUG_RETURN(rc);
- String derived_query(query_buff, sizeof(query_buff), thd->charset());
- derived_query.length(0);
- derived->derived->print(&derived_query, QT_ORDINARY);
-
- if ((*iop)->query(derived_query.ptr(), derived_query.length()))
+ if ((*iop)->query(derived->derived_spec.str, derived->derived_spec.length))
goto err;
stored_result= (*iop)->store_result();
1
0
[Commits] 15fe81c: MDEV-16188 Post merge fixes: trying to get rid of Windows warnings.
by IgorBabaev 09 Feb '19
by IgorBabaev 09 Feb '19
09 Feb '19
revision-id: 15fe81c571ef81ec834ac91f96c9adb4343ecd05 (mariadb-10.3.6-111-g15fe81c)
parent(s): 9fe1e83df0be36b6b3bea4ff67cc513f73e94c6e
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-09 10:54:26 -0800
message:
MDEV-16188 Post merge fixes: trying to get rid of Windows warnings.
---
.../suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff | 9 ---------
sql/rowid_filter.h | 4 ++--
sql/sql_explain.cc | 2 +-
3 files changed, 3 insertions(+), 12 deletions(-)
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
index d57c342..cb9e84b 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
@@ -507,15 +507,6 @@
VARIABLE_COMMENT Maximum stored procedure recursion depth
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 255
-@@ -2485,7 +2485,7 @@
- VARIABLE_TYPE BIGINT UNSIGNED
- VARIABLE_COMMENT The maximum size of the container of a rowid filter
- NUMERIC_MIN_VALUE 1024
--NUMERIC_MAX_VALUE 18446744073709551615
-+NUMERIC_MAX_VALUE 4294967295
- NUMERIC_BLOCK_SIZE 1
- ENUM_VALUE_LIST NULL
- READ_ONLY NO
@@ -2494,7 +2494,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 32
diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h
index ddeb13a..3195e76 100644
--- a/sql/rowid_filter.h
+++ b/sql/rowid_filter.h
@@ -138,7 +138,7 @@
*/
-class TABLE;
+struct TABLE;
class SQL_SELECT;
class Rowid_filter_container;
class Range_rowid_filter_cost_info;
@@ -331,7 +331,7 @@ class Refpos_container_sorted_array : public Sql_alloc
return array->get_pos(n * elem_size);
}
- uint elements() { return array->elements() / elem_size; }
+ uint elements() { return (uint) (array->elements() / elem_size); }
void sort (int (*cmp) (void *ctxt, const void *el1, const void *el2),
void *cmp_arg)
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index d5575dd..a53b357 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1639,7 +1639,7 @@ void Explain_rowid_filter::print_explain_json(Explain_query *query,
writer->add_member("r_selectivity_pct").
add_double(tracker->get_r_selectivity_pct() * 100.0);
writer->add_member("r_buffer_size").
- add_double(tracker->get_container_buff_size());
+ add_double((double) (tracker->get_container_buff_size()));
writer->add_member("r_filling_time_ms").
add_double(tracker->get_time_fill_container_ms());
}
1
0
[Commits] 985f85d: MDEV-16188 Post merge fixes: trying to get rid of Windows warnings.
by IgorBabaev 09 Feb '19
by IgorBabaev 09 Feb '19
09 Feb '19
revision-id: 985f85d0c9a1da497489e6cd0d53edb02c64ebbe (mariadb-10.3.6-111-g985f85d)
parent(s): 9fe1e83df0be36b6b3bea4ff67cc513f73e94c6e
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-08 22:26:42 -0800
message:
MDEV-16188 Post merge fixes: trying to get rid of Windows warnings.
---
.../suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff | 9 ---------
sql/rowid_filter.h | 2 +-
sql/sql_explain.cc | 2 +-
3 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
index d57c342..cb9e84b 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
@@ -507,15 +507,6 @@
VARIABLE_COMMENT Maximum stored procedure recursion depth
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 255
-@@ -2485,7 +2485,7 @@
- VARIABLE_TYPE BIGINT UNSIGNED
- VARIABLE_COMMENT The maximum size of the container of a rowid filter
- NUMERIC_MIN_VALUE 1024
--NUMERIC_MAX_VALUE 18446744073709551615
-+NUMERIC_MAX_VALUE 4294967295
- NUMERIC_BLOCK_SIZE 1
- ENUM_VALUE_LIST NULL
- READ_ONLY NO
@@ -2494,7 +2494,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 32
diff --git a/sql/rowid_filter.h b/sql/rowid_filter.h
index ddeb13a..627a427 100644
--- a/sql/rowid_filter.h
+++ b/sql/rowid_filter.h
@@ -138,7 +138,7 @@
*/
-class TABLE;
+struct TABLE;
class SQL_SELECT;
class Rowid_filter_container;
class Range_rowid_filter_cost_info;
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index d5575dd..a53b357 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1639,7 +1639,7 @@ void Explain_rowid_filter::print_explain_json(Explain_query *query,
writer->add_member("r_selectivity_pct").
add_double(tracker->get_r_selectivity_pct() * 100.0);
writer->add_member("r_buffer_size").
- add_double(tracker->get_container_buff_size());
+ add_double((double) (tracker->get_container_buff_size()));
writer->add_member("r_filling_time_ms").
add_double(tracker->get_time_fill_container_ms());
}
1
0
revision-id: 9fe1e83df0be36b6b3bea4ff67cc513f73e94c6e (mariadb-10.3.6-110-g9fe1e83)
parent(s): 651347b6c1133e8b666703b75f478a2fb565c73d
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-08 12:32:31 -0800
message:
MDEV-16188 Post merge fixes: more for TokuDB
---
mysql-test/suite/heap/heap_btree.result | 2 +-
mysql-test/suite/heap/heap_btree.test | 1 +
mysql-test/suite/heap/heap_hash.result | 5 +++--
mysql-test/suite/heap/heap_hash.test | 4 ++--
mysql-test/suite/innodb/r/mdev-117.result | 2 --
.../sys_vars/r/sysvars_server_notembedded,32bit.rdiff | 9 +++++++++
sql/sql_explain.cc | 3 ++-
storage/sequence/mysql-test/sequence/simple.result | 4 ++--
storage/sequence/mysql-test/sequence/simple.test | 2 +-
.../tokudb_alter_table/r/hcad_with_lock_sps.result | 12 ++++++------
storage/tokudb/mysql-test/tokudb_bugs/r/2970.result | 2 +-
.../tokudb/mysql-test/tokudb_bugs/r/5733_innodb.result | 8 ++++----
.../tokudb/mysql-test/tokudb_bugs/r/5733_tokudb.result | 2 +-
.../tokudb/mysql-test/tokudb_bugs/r/bulk_fetch.result | 8 +++-----
.../tokudb/mysql-test/tokudb_bugs/r/index_read.result | 6 ++----
storage/tokudb/mysql-test/tokudb_bugs/t/bulk_fetch.test | 4 ++--
storage/tokudb/mysql-test/tokudb_bugs/t/index_read.test | 4 ++--
.../mysql-test/tokudb_mariadb/r/clustering.result | 17 +++++++++++++----
.../tokudb/mysql-test/tokudb_mariadb/t/clustering.test | 5 +++--
19 files changed, 58 insertions(+), 42 deletions(-)
diff --git a/mysql-test/suite/heap/heap_btree.result b/mysql-test/suite/heap/heap_btree.result
index 28292d9..5985350 100644
--- a/mysql-test/suite/heap/heap_btree.result
+++ b/mysql-test/suite/heap/heap_btree.result
@@ -48,8 +48,8 @@ a
alter table t1 add unique uniq_id using BTREE (a);
select * from t1 where a > 736494;
a
-869751
802616
+869751
select * from t1 where a = 736494;
a
736494
diff --git a/mysql-test/suite/heap/heap_btree.test b/mysql-test/suite/heap/heap_btree.test
index aca41c4..6e087c7 100644
--- a/mysql-test/suite/heap/heap_btree.test
+++ b/mysql-test/suite/heap/heap_btree.test
@@ -37,6 +37,7 @@ create table t1 (a int not null) engine=heap;
insert into t1 values (869751),(736494),(226312),(802616),(728912);
select * from t1 where a > 736494;
alter table t1 add unique uniq_id using BTREE (a);
+--sorted_result
select * from t1 where a > 736494;
select * from t1 where a = 736494;
select * from t1 where a=869751 or a=736494;
diff --git a/mysql-test/suite/heap/heap_hash.result b/mysql-test/suite/heap/heap_hash.result
index 4f96827..987de12 100644
--- a/mysql-test/suite/heap/heap_hash.result
+++ b/mysql-test/suite/heap/heap_hash.result
@@ -426,13 +426,14 @@ select 0+a from t1 where a=869751 or a=736494;
explain select 0+a from t1 where a=869751 or a=736494;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range uniq_id uniq_id 8 NULL 2 Using where
-select 0+a from t1 where a in (869751,736494,226312,802616);
+select 0+a from t1 where a in (869751,736494,226312,802616,728912);
0+a
869751
736494
226312
802616
-explain select 0+a from t1 where a in (869751,736494,226312,802616);
+728912
+explain select 0+a from t1 where a in (869751,736494,226312,802616,728912);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL uniq_id NULL NULL NULL 5 Using where
drop table t1;
diff --git a/mysql-test/suite/heap/heap_hash.test b/mysql-test/suite/heap/heap_hash.test
index 3fe95e1..3a8979a 100644
--- a/mysql-test/suite/heap/heap_hash.test
+++ b/mysql-test/suite/heap/heap_hash.test
@@ -313,8 +313,8 @@ select 0+a from t1 where a = 736494;
explain select 0+a from t1 where a = 736494;
select 0+a from t1 where a=869751 or a=736494;
explain select 0+a from t1 where a=869751 or a=736494;
-select 0+a from t1 where a in (869751,736494,226312,802616);
-explain select 0+a from t1 where a in (869751,736494,226312,802616);
+select 0+a from t1 where a in (869751,736494,226312,802616,728912);
+explain select 0+a from t1 where a in (869751,736494,226312,802616,728912);
drop table t1;
--echo End of 5.3 tests
diff --git a/mysql-test/suite/innodb/r/mdev-117.result b/mysql-test/suite/innodb/r/mdev-117.result
index 39a1fc5..979f1ae 100644
--- a/mysql-test/suite/innodb/r/mdev-117.result
+++ b/mysql-test/suite/innodb/r/mdev-117.result
@@ -12,8 +12,6 @@ DELETE IGNORE FROM t1;;
connection con1;
DELETE FROM t1 WHERE col_int_key IN (1, 40000000);
connection default;
-Warnings:
-Warning 1205 Lock wait timeout exceeded; try restarting transaction
disconnect con1;
drop table t1;
SET GLOBAL innodb_lock_wait_timeout=default;
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
index cb9e84b..d57c342 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded,32bit.rdiff
@@ -507,6 +507,15 @@
VARIABLE_COMMENT Maximum stored procedure recursion depth
NUMERIC_MIN_VALUE 0
NUMERIC_MAX_VALUE 255
+@@ -2485,7 +2485,7 @@
+ VARIABLE_TYPE BIGINT UNSIGNED
+ VARIABLE_COMMENT The maximum size of the container of a rowid filter
+ NUMERIC_MIN_VALUE 1024
+-NUMERIC_MAX_VALUE 18446744073709551615
++NUMERIC_MAX_VALUE 4294967295
+ NUMERIC_BLOCK_SIZE 1
+ ENUM_VALUE_LIST NULL
+ READ_ONLY NO
@@ -2494,7 +2494,7 @@
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 32
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc
index 0e7f8f3..d5575dd 100644
--- a/sql/sql_explain.cc
+++ b/sql/sql_explain.cc
@@ -1357,7 +1357,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai
if (rowid_filter)
{
r_rows_str.append(" (");
- r_rows_str.append_ulonglong(rowid_filter->tracker->get_r_selectivity_pct() * 100.0);
+ r_rows_str.append_ulonglong(
+ (ulonglong) (rowid_filter->tracker->get_r_selectivity_pct() * 100.0));
r_rows_str.append("%)");
}
item_list.push_back(new (mem_root)
diff --git a/storage/sequence/mysql-test/sequence/simple.result b/storage/sequence/mysql-test/sequence/simple.result
index ea94e91..d921b80 100644
--- a/storage/sequence/mysql-test/sequence/simple.result
+++ b/storage/sequence/mysql-test/sequence/simple.result
@@ -124,9 +124,9 @@ Tables_in_test
explain select * from seq_1_to_15_step_2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE seq_1_to_15_step_2 index NULL PRIMARY 8 NULL 8 Using index
-explain select * from seq_1_to_15_step_2 where seq > 4;
+explain select * from seq_1_to_15_step_2 where seq > 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE seq_1_to_15_step_2 range PRIMARY PRIMARY 8 NULL 6 Using where; Using index
+1 SIMPLE seq_1_to_15_step_2 range PRIMARY PRIMARY 8 NULL 3 Using where; Using index
explain select * from seq_1_to_15_step_2 where seq between 4 and 9;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE seq_1_to_15_step_2 range PRIMARY PRIMARY 8 NULL 3 Using where; Using index
diff --git a/storage/sequence/mysql-test/sequence/simple.test b/storage/sequence/mysql-test/sequence/simple.test
index fbf2b0e..00d2464 100644
--- a/storage/sequence/mysql-test/sequence/simple.test
+++ b/storage/sequence/mysql-test/sequence/simple.test
@@ -52,7 +52,7 @@ show open tables from test;
show tables;
# row estimates
explain select * from seq_1_to_15_step_2;
-explain select * from seq_1_to_15_step_2 where seq > 4;
+explain select * from seq_1_to_15_step_2 where seq > 10;
explain select * from seq_1_to_15_step_2 where seq between 4 and 9;
explain select * from seq_1_to_15_step_2 where seq between 20 and 30;
explain select * from seq_1_to_15_step_2 where seq between 4 and 6;
diff --git a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
index 88f2836..80402df 100644
--- a/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
+++ b/storage/tokudb/mysql-test/tokudb_alter_table/r/hcad_with_lock_sps.result
@@ -20,7 +20,7 @@ z a b c
999 4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
select* from foo where b > 10;
z a b c
999 2 20 200
@@ -40,7 +40,7 @@ a b c
4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
select* from foo where b > 10;
a b c
2 20 200
@@ -59,7 +59,7 @@ a b c z
4 40 400 NULL
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
select* from foo where b > 10;
a b c z
2 20 200 NULL
@@ -94,7 +94,7 @@ a b c
3 30 300
4 40 400
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
a b c
2 20 200
3 30 300
@@ -110,7 +110,7 @@ a b c
4 40 400
explain select * from foo where b > 20;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 2 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 4 Using where; Using index
select* from foo where b > 10;
a b c
2 20 200
@@ -154,7 +154,7 @@ a b c g
4 40 400 NULL
5 50 500 NULL
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range b b 5 NULL 3 Using where; Using index
+1 SIMPLE foo index b b 5 NULL 5 Using where; Using index
set autocommit=on;
explain select * from foo;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result b/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result
index 83ba882..c322865 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/2970.result
@@ -6,5 +6,5 @@ create table t2970 (a int, b int, c int, d int, key(a), key(a,b));
insert into t2970 values (1,1,1,1),(1,2,3,4);
explain select a,count(b),max(b) from t2970 where a > 0 group by a order by a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2970 index a,a_2 a_2 10 NULL 2 Using where; Using index
+1 SIMPLE t2970 range a,a_2 a_2 5 NULL 2 Using where; Using index
drop table t2970;
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/5733_innodb.result b/storage/tokudb/mysql-test/tokudb_bugs/r/5733_innodb.result
index 10cdb47..ba21899 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/5733_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/5733_innodb.result
@@ -10003,25 +10003,25 @@ insert into t values (9998,0);
insert into t values (9999,0);
explain select id from t where id>0 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t index PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t where id>0 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
explain select id from t where id>1000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t index PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t where id>1000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
explain select id from t where id>5000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t index PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t where id>5000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
explain select id from t where id>6000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t index PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t where id>6000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/5733_tokudb.result b/storage/tokudb/mysql-test/tokudb_bugs/r/5733_tokudb.result
index 1db2c57..0a736a9 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/5733_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/5733_tokudb.result
@@ -10009,7 +10009,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
explain select id from t where id>1000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where; Using index
+1 SIMPLE t index PRIMARY PRIMARY 8 NULL # Using where; Using index
explain select * from t where id>1000 limit 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t range PRIMARY PRIMARY 8 NULL # Using where
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/bulk_fetch.result b/storage/tokudb/mysql-test/tokudb_bugs/r/bulk_fetch.result
index 86943c2..70201e3 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/bulk_fetch.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/bulk_fetch.result
@@ -60,13 +60,11 @@ c
400
500
600
-explain select * from foo where c > 300;
+explain select * from foo where c > 500;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range c c 5 NULL 3 Using where; Using index
-select * from foo where c > 300;
+1 SIMPLE foo range c c 5 NULL 1 Using where; Using index
+select * from foo where c > 500;
a b c
-4 40 400
-5 50 500
6 60 600
drop table foo;
create table foo (a int, b int);
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/r/index_read.result b/storage/tokudb/mysql-test/tokudb_bugs/r/index_read.result
index 5d5c4d4..5a5ba28 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/r/index_read.result
+++ b/storage/tokudb/mysql-test/tokudb_bugs/r/index_read.result
@@ -150,13 +150,11 @@ a b c
2 20 200
1 100 100
1 10 100
-explain select * from foo where a>=4;
+explain select * from foo where a>=5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE foo range a a 4 NULL NULL; Using where
-select * from foo where a>=4;
+select * from foo where a>=5;
a b c
-4 40 400
-4 400 400
5 50 500
5 500 500
6 60 600
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/bulk_fetch.test b/storage/tokudb/mysql-test/tokudb_bugs/t/bulk_fetch.test
index 41b8f1f..11ce1e7 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/t/bulk_fetch.test
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/bulk_fetch.test
@@ -26,8 +26,8 @@ alter table foo drop index b;
alter table foo add index c(c) clustering=yes;
select c from foo;
-explain select * from foo where c > 300;
-select * from foo where c > 300;
+explain select * from foo where c > 500;
+select * from foo where c > 500;
drop table foo;
# simple test on hidden primary key
diff --git a/storage/tokudb/mysql-test/tokudb_bugs/t/index_read.test b/storage/tokudb/mysql-test/tokudb_bugs/t/index_read.test
index 0366441..c79a634 100644
--- a/storage/tokudb/mysql-test/tokudb_bugs/t/index_read.test
+++ b/storage/tokudb/mysql-test/tokudb_bugs/t/index_read.test
@@ -117,8 +117,8 @@ select * from foo where a<3 order by a desc;
#HA_READ_KEY_OR_NEXT
# ignore rows column
--replace_column 9 NULL;
-explain select * from foo where a>=4;
-select * from foo where a>=4;
+explain select * from foo where a>=5;
+select * from foo where a>=5;
#HA_READ_KEY_OR_PREV not used anymore
diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/r/clustering.result b/storage/tokudb/mysql-test/tokudb_mariadb/r/clustering.result
index 28c758f..fca204e 100644
--- a/storage/tokudb/mysql-test/tokudb_mariadb/r/clustering.result
+++ b/storage/tokudb/mysql-test/tokudb_mariadb/r/clustering.result
@@ -12,6 +12,7 @@ insert t1 values (1, 1, 1);
insert t1 select a+1, a+1, a+1 from t1;
insert t1 select a+2, a+2, a+2 from t1;
insert t1 select a+4, a+4, a+4 from t1;
+insert t1 select a+8, a+8, a+8 from t1;
select * from t1;
a b c
1 1 1
@@ -22,10 +23,18 @@ a b c
6 6 6
7 7 7
8 8 8
-explain select a,c from t1 where a > 2;
+9 9 9
+10 10 10
+11 11 11
+12 12 12
+13 13 13
+14 14 14
+15 15 15
+16 16 16
+explain select a,c from t1 where a > 4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 6 Using where; Using index
-explain select b,c from t1 where b > 2;
+1 SIMPLE t1 index a a 5 NULL 16 Using where; Using index
+explain select b,c from t1 where b > 4;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL b NULL NULL NULL 8 Using where
+1 SIMPLE t1 ALL b NULL NULL NULL 16 Using where
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb_mariadb/t/clustering.test b/storage/tokudb/mysql-test/tokudb_mariadb/t/clustering.test
index 58d806e..ce7ef42 100644
--- a/storage/tokudb/mysql-test/tokudb_mariadb/t/clustering.test
+++ b/storage/tokudb/mysql-test/tokudb_mariadb/t/clustering.test
@@ -6,10 +6,11 @@ insert t1 values (1, 1, 1);
insert t1 select a+1, a+1, a+1 from t1;
insert t1 select a+2, a+2, a+2 from t1;
insert t1 select a+4, a+4, a+4 from t1;
+insert t1 select a+8, a+8, a+8 from t1;
select * from t1;
-explain select a,c from t1 where a > 2;
-explain select b,c from t1 where b > 2;
+explain select a,c from t1 where a > 4;
+explain select b,c from t1 where b > 4;
drop table t1;
1
0
revision-id: 651347b6c1133e8b666703b75f478a2fb565c73d (mariadb-10.3.6-109-g651347b)
parent(s): 6cb2ab53284a64e0f2aba48f458cd4a6028a4639
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-08 01:07:27 -0800
message:
MDEV-16188 Post merge fixes fot TokuDB
---
mysql-test/main/func_in.result | 4 +-
.../main/myisam_explain_non_select_all.result | 6 +-
mysql-test/main/myisam_icp.result | 2 +-
mysql-test/main/order_by.result | 2 +-
mysql-test/main/partition_pruning.result | 8 +-
sql/handler.h | 2 +
sql/multi_range_read.cc | 19 ++-
storage/tokudb/ha_tokudb.cc | 20 +--
storage/tokudb/ha_tokudb.h | 1 +
.../mysql-test/tokudb/include/cluster_key.inc | 73 ++++-----
.../mysql-test/tokudb/r/cluster_2968-2.result | 2 +-
.../tokudb/r/cluster_create_table.result | 8 +-
.../mysql-test/tokudb/r/cluster_delete.result | 128 +++++++++-------
.../mysql-test/tokudb/r/cluster_filter_key.result | 13 +-
.../tokudb/mysql-test/tokudb/r/cluster_key.result | 165 +++++++++++----------
.../mysql-test/tokudb/r/cluster_query_plan.result | 8 +-
.../tokudb/r/cluster_tokudb_bug_993_2.result | 4 +-
.../mysql-test/tokudb/r/cluster_update.result | 115 ++++++++------
.../mysql-test/tokudb/r/ext_key_1_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_1_tokudb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_tokudb.result | 2 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-29.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-30.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-31.result | 4 +-
.../tokudb/mysql-test/tokudb/r/tokudb_mrr.result | 12 +-
storage/tokudb/mysql-test/tokudb/r/type_bit.result | 2 +-
.../tokudb/mysql-test/tokudb/r/type_blob.result | 4 +-
.../mysql-test/tokudb/t/cluster_create_table.test | 4 +-
.../tokudb/mysql-test/tokudb/t/cluster_delete.test | 50 ++++---
.../mysql-test/tokudb/t/cluster_filter_key.test | 8 +-
.../mysql-test/tokudb/t/cluster_query_plan.test | 8 +-
.../tokudb/mysql-test/tokudb/t/cluster_update.test | 43 +++---
storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test | 8 +-
34 files changed, 415 insertions(+), 324 deletions(-)
diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result
index 9a3c1db..79f5f55 100644
--- a/mysql-test/main/func_in.result
+++ b/mysql-test/main/func_in.result
@@ -717,11 +717,11 @@ id select_type table type possible_keys key key_len ref rows Extra
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN ('2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using index condition
+1 SIMPLE t1 ALL c_timestamp NULL NULL NULL 20 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp
IN (NULL, '2009-09-01 00:00:01', '2009-09-01 00:00:02', '2009-09-01 00:00:03');
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c_timestamp c_timestamp 4 NULL 3 Using index condition
+1 SIMPLE t1 ALL c_timestamp NULL NULL NULL 20 Using where
EXPLAIN SELECT * FROM t1 WHERE c_timestamp IN (NULL);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result
index bfc8370..c3d3b67 100644
--- a/mysql-test/main/myisam_explain_non_select_all.result
+++ b/mysql-test/main/myisam_explain_non_select_all.result
@@ -735,12 +735,12 @@ Warnings:
Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
EXPLAIN DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 1 Using where; Using filesort
FLUSH STATUS;
FLUSH TABLES;
EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a;
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+1 SIMPLE t1 ALL PRIMARY NULL NULL NULL 1 100.00 Using where; Using filesort
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 3
@@ -764,6 +764,8 @@ Handler_read_rnd_next 1
# Status of testing query execution:
Variable_name Value
Handler_read_key 3
+Handler_read_rnd_next 1
+Sort_scan 1
INSERT INTO t1 VALUES (1), (2), (3), (-1), (-2), (-3);
#
diff --git a/mysql-test/main/myisam_icp.result b/mysql-test/main/myisam_icp.result
index 39c76a2..577a0df 100644
--- a/mysql-test/main/myisam_icp.result
+++ b/mysql-test/main/myisam_icp.result
@@ -506,7 +506,7 @@ WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 Using index condition; Using where; Rowid-ordered scan
-1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 2 Using index condition; Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
+1 SIMPLE t2 ALL PRIMARY NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
SELECT c2 FROM t1 JOIN t2 ON t1.c1 = t2.c1
WHERE (t2.pk <= 4 AND t1.pk IN (2,1)) OR
(t1.pk > 1 AND t2.pk BETWEEN 6 AND 6);
diff --git a/mysql-test/main/order_by.result b/mysql-test/main/order_by.result
index f5bae1c..fcc34a2 100644
--- a/mysql-test/main/order_by.result
+++ b/mysql-test/main/order_by.result
@@ -714,7 +714,7 @@ FieldKey LongVal StringVal
3 3 3
EXPLAIN SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 3 Using where
+1 SIMPLE t1 range FieldKey,LongField,StringField LongField 38 NULL 3 Using index condition
SELECT * FROM t1 WHERE FieldKey > '2' ORDER BY FieldKey, LongVal;
FieldKey LongVal StringVal
3 1 2
diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result
index 6402f23..1576755 100644
--- a/mysql-test/main/partition_pruning.result
+++ b/mysql-test/main/partition_pruning.result
@@ -2676,13 +2676,13 @@ explain partitions
select * from t1 X, t1 Y
where X.b = Y.b and (X.a=1 or X.a=2) and (Y.a=2 or Y.a=3);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE X p1,p2 range a,b a 4 NULL 4 Using where
-1 SIMPLE Y p2,p3 ref|filter a,b b|a 4|4 test.X.b 2 (50%) Using where; Using rowid filter
+1 SIMPLE X p1,p2 ALL a,b NULL NULL NULL 8 Using where
+1 SIMPLE Y p2,p3 ALL a,b NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
explain partitions
select * from t1 X, t1 Y where X.a = Y.a and (X.a=1 or X.a=2);
id select_type table partitions type possible_keys key key_len ref rows Extra
-1 SIMPLE X p1,p2 range a a 4 NULL 4 Using where
-1 SIMPLE Y p1,p2 ref a a 4 test.X.a 2
+1 SIMPLE X p1,p2 ALL a NULL NULL NULL 8 Using where
+1 SIMPLE Y p1,p2 ALL a NULL NULL NULL 8 Using where; Using join buffer (flat, BNL join)
drop table t1;
create table t1 (a int) partition by hash(a) partitions 20;
insert into t1 values (1),(2),(3);
diff --git a/sql/handler.h b/sql/handler.h
index 0836360..6f44c68 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -4748,6 +4748,8 @@ class handler :public Sql_alloc
virtual void update_partition(uint part_id)
{}
+ virtual bool is_clustering_key(uint index) { return false; }
+
protected:
Handler_share *get_ha_share_ptr();
void set_ha_share_ptr(Handler_share *arg_ha_share);
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 12f72f5..027d2f7 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -20,10 +20,16 @@
#include "key.h"
#include "sql_statistics.h"
-static ulonglong key_block_no(handler *h, uint keyno, ha_rows keyentry_pos)
+static ulonglong key_block_no(TABLE *table, uint keyno, ha_rows keyentry_pos)
{
- return (ulonglong) (h->keyread_time(keyno, 1, keyentry_pos + 1) -
- h->keyread_time(keyno, 0, keyentry_pos + 1) + 0.5) + 1;
+ size_t len= table->key_info[keyno].key_length + table->file->ref_length;
+ if (keyno == table->s->primary_key &&
+ table->file->primary_key_is_clustered())
+ len= table->s->stored_rec_length;
+ uint keys_per_block= (uint) (table->file->stats.block_size/2.0/len+1);
+ ulonglong block_no= !keyentry_pos ? 0 :
+ (keyentry_pos - 1) / keys_per_block + 1;
+ return block_no;
}
/****************************************************************************
@@ -177,8 +183,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
}
min_pos+= r - rows;
}
- min_block_no= key_block_no(this, keyno, min_pos);
- max_block_no= key_block_no(this, keyno, min_pos + rows);
+ min_block_no= key_block_no(this->table, keyno, min_pos);
+ max_block_no= key_block_no(this->table, keyno, min_pos + rows);
new_touched_blocks= max_block_no - min_block_no +
MY_TEST(min_block_no != prev_max_block_no);
prev_max_block_no= max_block_no;
@@ -202,7 +208,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
cost->reset();
cost->avg_io_cost= 1; /* assume random seeks */
cost->idx_avg_io_cost= 1;
- if (!(keyno == table->s->primary_key && primary_key_is_clustered()))
+ if (!((keyno == table->s->primary_key && primary_key_is_clustered()) ||
+ is_clustering_key(keyno)))
{
cost->idx_io_count= total_touched_blocks +
keyread_time(keyno, 0, total_rows);
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 4196440..b0f438b 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -7775,13 +7775,18 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val);
}
+bool ha_tokudb::is_clustering_key(uint index)
+{
+ return index == primary_key || key_is_clustering(&table->key_info[index]);
+}
+
double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
{
TOKUDB_HANDLER_DBUG_ENTER("%u %u %" PRIu64, index, ranges, (uint64_t) rows);
- double ret_val;
- if (index == primary_key || key_is_clustering(&table->key_info[index])) {
- ret_val = read_time(index, ranges, rows);
- DBUG_RETURN(ret_val);
+ double cost;
+ if (index == primary_key || is_clustering_key(index)) {
+ cost = read_time(index, ranges, rows);
+ DBUG_RETURN(cost);
}
/*
It is assumed that we will read trough the whole key range and that all
@@ -7791,11 +7796,8 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
blocks read. This model does not take into account clustered indexes -
engines that support that (e.g. InnoDB) may want to overwrite this method.
*/
- double keys_per_block= (stats.block_size/2.0/
- (table->key_info[index].key_length +
- ref_length) + 1);
- ret_val = (rows + keys_per_block - 1)/ keys_per_block;
- TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val);
+ cost= handler::keyread_time(index, ranges, rows);
+ TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(cost);
}
//
diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h
index 75fabbf..58121f9 100644
--- a/storage/tokudb/ha_tokudb.h
+++ b/storage/tokudb/ha_tokudb.h
@@ -871,6 +871,7 @@ class ha_tokudb : public handler {
bool primary_key_is_clustered() {
return true;
}
+ bool is_clustering_key(uint index);
int cmp_ref(const uchar * ref1, const uchar * ref2);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
diff --git a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
index d637b46..1914da1 100644
--- a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
+++ b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
@@ -1,7 +1,10 @@
# test for TokuDB clustering keys.
# test assumes that a table 't1' exists with the following columns:
# a int, b int, c int, d int
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -13,20 +16,20 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -35,8 +38,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 add index bdca(b,d,c,a) clustering=yes;
@@ -51,25 +54,25 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
alter table t1 add e varchar(20);
@@ -77,25 +80,25 @@ alter table t1 add primary key (a,b,c);
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -104,8 +107,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 drop primary key;
@@ -116,23 +119,23 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
index 4c3f971..b274996 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
@@ -1096,7 +1096,7 @@ t CREATE TABLE `t` (
explain select straight_join s.a,t.a from s,t where s.b = t.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index
-1 SIMPLE t ref b,b_2,b_3 b_2 5 test.s.b 1 Using index
+1 SIMPLE t ref b,b_2,b_3 b_3 5 test.s.b 1 Using index
alter table s drop key b_2;
alter table t drop key b_2;
show create table s;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
index 02a90c6..bbc886f 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
@@ -39,16 +39,20 @@ t1 CREATE TABLE `t1` (
KEY `foo` (`c`,`d`) `clustering`=yes,
KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes
) ENGINE=TokuDB DEFAULT CHARSET=latin1
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+(1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+(32,54,12,56);
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 16 NULL 5 Using index
+1 SIMPLE t1 index NULL PRIMARY 16 NULL 7 Using index
select * from t1;
a b c d
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
+5 5 5 5
+6 6 6 6
32 54 12 56
explain select d from t1 where d > 30;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
index 1fd519d..f858452 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,47 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 850;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
+select * from t1 where c > 850;
a b c d
-8 80 800 8000
9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-explain select a,b from t1 where b > 30;
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
delete from t1 where b>30 and b < 60;
select * from t1;
a b c d
@@ -63,15 +65,16 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where a > 5;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d
-6 60 600 6000
-7 70 700 7000
-8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -81,19 +84,25 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
+1 SIMPLE t1 index PRIMARY c 5 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -103,13 +112,14 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -120,22 +130,23 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 1050;
a b c d
-8 80 800 8000
-9 90 900 9000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -145,61 +156,76 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
delete from t1 where b > 10 and b < 90;
select * from t1;
a b c d
1 10 100 1000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select * from t1 where a > 5;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select a from t1 where a > 5;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30;
a b
9 90
+10 100
+11 110
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select a,c from t1 where c > 750;
a c
9 900
+10 1000
+11 1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
index a594b10..aa33246 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
@@ -7,22 +7,19 @@ insert into t1 values (2,"20",200);
insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
+explain select * from t1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 3 Using where
-select * from t1 where a > 2;
+1 SIMPLE t1 range a a 5 NULL 2 Using where
+select * from t1 where a > 3;
a b c
-3 30 300
4 40 400
5 50 500
-select b from t1 where a > 2;
+select b from t1 where a > 3;
b
-30
40
50
-select c from t1 where a > 2;
+select c from t1 where a > 3;
c
-300
400
500
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
index fab2880..4c2fc08 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,30 +14,30 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -46,13 +49,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 add index bdca(b,d,c,a) clustering=yes;
insert into t1 values (10,10,10,10);
alter table t1 drop index bdca;
@@ -67,79 +78,73 @@ a b c d
8 80 800 8000
9 90 900 9000
10 10 10 10
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select b from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
alter table t1 add e varchar(20);
alter table t1 add primary key (a,b,c);
-explain select * from t1 where a > 5;
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d e
-6 60 600 6000 NULL
-7 70 700 7000 NULL
-8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select a from t1 where a > 8;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -151,13 +156,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -169,40 +182,38 @@ a b c d e
8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select b from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
index c6754db..6b458b3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
@@ -2,16 +2,16 @@ SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
index 41abded..2dcb65c 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
@@ -32,13 +32,13 @@ max(a)
7
explain select a,b from z1 where a < 7;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 12 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 7;
max(a)
3
explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 3;
max(a)
1
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
index 14ab9a2..586cf2e 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,48 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -63,6 +66,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -74,6 +79,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -81,12 +88,14 @@ select * from t1 where c > 750;
a b c d
8 85 805 8000
9 95 905 9000
-explain select a from t1 where a > 8;
+10 105 1005 10000
+11 115 1105 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NA b b 5 NULL NULL; Using where; Using index
@@ -98,6 +107,8 @@ a b
7 75
8 85
9 95
+10 105
+11 115
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -105,6 +116,8 @@ select a,c from t1 where c > 750;
a c
8 805
9 905
+10 1005
+11 1105
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -115,24 +128,25 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where b > 30;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 45 405 4000
-5 55 505 5000
-6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where c > 750;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 85 805 8000
-9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -142,24 +156,25 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 45
-5 55
-6 65
7 75
8 85
9 95
-explain select a,b from t1 where c > 750;
+10 105
+11 115
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 805
-9 905
+10 1005
+11 1105
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
a b c d
@@ -172,6 +187,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -181,6 +198,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -192,6 +211,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -199,6 +220,8 @@ select * from t1 where c > 750;
a b c d
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -208,6 +231,8 @@ a
7
8
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -219,6 +244,8 @@ a b
7 80
8 90
9 100
+10 110
+11 120
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -226,4 +253,6 @@ select a,c from t1 where c > 750;
a c
8 810
9 910
+10 1010
+11 1110
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
index 2a0ee4f..55a2cc4 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
index 4580cc9..1b5998b 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
index fb998e3..0bba5b7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
index 9d9fb4c..556c5ff 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
index 994b906..f741dca 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
@@ -31,7 +31,7 @@ delete from foo where a > 5;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a > 1;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
index 6bf54ef..37701ef 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
@@ -31,7 +31,7 @@ delete from foo where a < 10;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
index cc2bb45..a404348 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
@@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1 and a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 8 values
select * from foo where a > 1 and a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
index 024580d..fd584a3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
+++ b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
@@ -305,25 +305,25 @@ dummy INT PRIMARY KEY,
a INT UNIQUE,
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
dummy a b
-3 3 3
-5 5 5
+8 8 8
+9 9 9
connection con2;
SET AUTOCOMMIT=0;
SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
connection con1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_bit.result b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
index c147c20..76a032d 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_bit.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort
+1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_blob.result b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
index 1350bc0..3f65967 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_blob.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
@@ -667,14 +667,14 @@ id txt
alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where; Using filesort
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort
select * from t1 where txt='Chevy' or txt is NULL order by txt;
id txt
3 NULL
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
index c2196bf..0cace80 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
@@ -22,7 +22,9 @@ alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d);
alter table t1 add key bar(d,c,b,a) clustering=yes;
show create table t1;
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+ (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+ (32,54,12,56);
explain select * from t1;
select * from t1;
explain select d from t1 where d > 30;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
index 1c0ebad..cb49092 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
@@ -7,8 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
-
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -19,38 +21,38 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 850;
+select * from t1 where c > 850;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
delete from t1 where b>30 and b < 60;
select * from t1;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
@@ -76,8 +78,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
alter table t1 drop primary key;
@@ -88,13 +90,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 1050;
+select * from t1 where c > 1050;
#covering indexes
@@ -105,13 +107,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
delete from t1 where b > 10 and b < 90;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
index 192e56f..dc788d5 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
@@ -13,10 +13,10 @@ insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
-select * from t1 where a > 2;
-select b from t1 where a > 2;
-select c from t1 where a > 2;
+explain select * from t1 where a > 3;
+select * from t1 where a > 3;
+select b from t1 where a > 3;
+select c from t1 where a > 3;
#explain delete from t1 where a <2;
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
index a438653..23207f2 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
@@ -11,18 +11,18 @@ insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
# ignore rows column
--replace_column 9 NULL;
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
index ce5a025..42a004f 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
@@ -7,7 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -19,30 +22,30 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
+explain select a from t1 where a > 10;
select a from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
@@ -64,8 +67,8 @@ select * from t1 where c > 750;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 4 NA 9 NULL;
@@ -86,13 +89,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
@@ -102,13 +105,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
diff --git a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
index 6130933..dcee594 100644
--- a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
+++ b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
@@ -40,16 +40,16 @@ CREATE TABLE t1 (
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
connection con2;
@@ -58,7 +58,7 @@ SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
--error ER_LOCK_WAIT_TIMEOUT
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ROLLBACK;
connection con1;
1
0
revision-id: 876044ee0a7d98bc0242fec1b88fed2360863a1b (mariadb-10.3.6-108-g876044e)
parent(s): 9e114455a95c15cd1e37dabef0dff1fe2588d50a
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-08 00:03:09 -0800
message:
MDEV-16188 Post merge fixes fot TokuDB
---
sql/handler.h | 2 +
sql/multi_range_read.cc | 19 ++-
storage/tokudb/ha_tokudb.cc | 20 +--
storage/tokudb/ha_tokudb.h | 1 +
.../mysql-test/tokudb/include/cluster_key.inc | 73 ++++-----
.../mysql-test/tokudb/r/cluster_2968-2.result | 2 +-
.../tokudb/r/cluster_create_table.result | 8 +-
.../mysql-test/tokudb/r/cluster_delete.result | 128 +++++++++-------
.../mysql-test/tokudb/r/cluster_filter_key.result | 13 +-
.../tokudb/mysql-test/tokudb/r/cluster_key.result | 165 +++++++++++----------
.../mysql-test/tokudb/r/cluster_query_plan.result | 8 +-
.../tokudb/r/cluster_tokudb_bug_993_2.result | 4 +-
.../mysql-test/tokudb/r/cluster_update.result | 115 ++++++++------
.../mysql-test/tokudb/r/ext_key_1_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_1_tokudb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_tokudb.result | 2 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-29.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-30.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-31.result | 4 +-
.../tokudb/mysql-test/tokudb/r/tokudb_mrr.result | 12 +-
storage/tokudb/mysql-test/tokudb/r/type_bit.result | 2 +-
.../tokudb/mysql-test/tokudb/r/type_blob.result | 4 +-
.../mysql-test/tokudb/t/cluster_create_table.test | 4 +-
.../tokudb/mysql-test/tokudb/t/cluster_delete.test | 50 ++++---
.../mysql-test/tokudb/t/cluster_filter_key.test | 8 +-
.../mysql-test/tokudb/t/cluster_query_plan.test | 8 +-
.../tokudb/mysql-test/tokudb/t/cluster_update.test | 43 +++---
storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test | 8 +-
29 files changed, 403 insertions(+), 314 deletions(-)
diff --git a/sql/handler.h b/sql/handler.h
index 0836360..6f44c68 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -4748,6 +4748,8 @@ class handler :public Sql_alloc
virtual void update_partition(uint part_id)
{}
+ virtual bool is_clustering_key(uint index) { return false; }
+
protected:
Handler_share *get_ha_share_ptr();
void set_ha_share_ptr(Handler_share *arg_ha_share);
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 12f72f5..027d2f7 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -20,10 +20,16 @@
#include "key.h"
#include "sql_statistics.h"
-static ulonglong key_block_no(handler *h, uint keyno, ha_rows keyentry_pos)
+static ulonglong key_block_no(TABLE *table, uint keyno, ha_rows keyentry_pos)
{
- return (ulonglong) (h->keyread_time(keyno, 1, keyentry_pos + 1) -
- h->keyread_time(keyno, 0, keyentry_pos + 1) + 0.5) + 1;
+ size_t len= table->key_info[keyno].key_length + table->file->ref_length;
+ if (keyno == table->s->primary_key &&
+ table->file->primary_key_is_clustered())
+ len= table->s->stored_rec_length;
+ uint keys_per_block= (uint) (table->file->stats.block_size/2.0/len+1);
+ ulonglong block_no= !keyentry_pos ? 0 :
+ (keyentry_pos - 1) / keys_per_block + 1;
+ return block_no;
}
/****************************************************************************
@@ -177,8 +183,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
}
min_pos+= r - rows;
}
- min_block_no= key_block_no(this, keyno, min_pos);
- max_block_no= key_block_no(this, keyno, min_pos + rows);
+ min_block_no= key_block_no(this->table, keyno, min_pos);
+ max_block_no= key_block_no(this->table, keyno, min_pos + rows);
new_touched_blocks= max_block_no - min_block_no +
MY_TEST(min_block_no != prev_max_block_no);
prev_max_block_no= max_block_no;
@@ -202,7 +208,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
cost->reset();
cost->avg_io_cost= 1; /* assume random seeks */
cost->idx_avg_io_cost= 1;
- if (!(keyno == table->s->primary_key && primary_key_is_clustered()))
+ if (!((keyno == table->s->primary_key && primary_key_is_clustered()) ||
+ is_clustering_key(keyno)))
{
cost->idx_io_count= total_touched_blocks +
keyread_time(keyno, 0, total_rows);
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 4196440..b0f438b 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -7775,13 +7775,18 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val);
}
+bool ha_tokudb::is_clustering_key(uint index)
+{
+ return index == primary_key || key_is_clustering(&table->key_info[index]);
+}
+
double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
{
TOKUDB_HANDLER_DBUG_ENTER("%u %u %" PRIu64, index, ranges, (uint64_t) rows);
- double ret_val;
- if (index == primary_key || key_is_clustering(&table->key_info[index])) {
- ret_val = read_time(index, ranges, rows);
- DBUG_RETURN(ret_val);
+ double cost;
+ if (index == primary_key || is_clustering_key(index)) {
+ cost = read_time(index, ranges, rows);
+ DBUG_RETURN(cost);
}
/*
It is assumed that we will read trough the whole key range and that all
@@ -7791,11 +7796,8 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
blocks read. This model does not take into account clustered indexes -
engines that support that (e.g. InnoDB) may want to overwrite this method.
*/
- double keys_per_block= (stats.block_size/2.0/
- (table->key_info[index].key_length +
- ref_length) + 1);
- ret_val = (rows + keys_per_block - 1)/ keys_per_block;
- TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val);
+ cost= handler::keyread_time(index, ranges, rows);
+ TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(cost);
}
//
diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h
index 75fabbf..58121f9 100644
--- a/storage/tokudb/ha_tokudb.h
+++ b/storage/tokudb/ha_tokudb.h
@@ -871,6 +871,7 @@ class ha_tokudb : public handler {
bool primary_key_is_clustered() {
return true;
}
+ bool is_clustering_key(uint index);
int cmp_ref(const uchar * ref1, const uchar * ref2);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
diff --git a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
index d637b46..1914da1 100644
--- a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
+++ b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
@@ -1,7 +1,10 @@
# test for TokuDB clustering keys.
# test assumes that a table 't1' exists with the following columns:
# a int, b int, c int, d int
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -13,20 +16,20 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -35,8 +38,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 add index bdca(b,d,c,a) clustering=yes;
@@ -51,25 +54,25 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
alter table t1 add e varchar(20);
@@ -77,25 +80,25 @@ alter table t1 add primary key (a,b,c);
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -104,8 +107,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 drop primary key;
@@ -116,23 +119,23 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
index 4c3f971..b274996 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
@@ -1096,7 +1096,7 @@ t CREATE TABLE `t` (
explain select straight_join s.a,t.a from s,t where s.b = t.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index
-1 SIMPLE t ref b,b_2,b_3 b_2 5 test.s.b 1 Using index
+1 SIMPLE t ref b,b_2,b_3 b_3 5 test.s.b 1 Using index
alter table s drop key b_2;
alter table t drop key b_2;
show create table s;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
index 02a90c6..bbc886f 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
@@ -39,16 +39,20 @@ t1 CREATE TABLE `t1` (
KEY `foo` (`c`,`d`) `clustering`=yes,
KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes
) ENGINE=TokuDB DEFAULT CHARSET=latin1
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+(1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+(32,54,12,56);
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 16 NULL 5 Using index
+1 SIMPLE t1 index NULL PRIMARY 16 NULL 7 Using index
select * from t1;
a b c d
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
+5 5 5 5
+6 6 6 6
32 54 12 56
explain select d from t1 where d > 30;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
index 1fd519d..f858452 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,47 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 850;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
+select * from t1 where c > 850;
a b c d
-8 80 800 8000
9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-explain select a,b from t1 where b > 30;
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
delete from t1 where b>30 and b < 60;
select * from t1;
a b c d
@@ -63,15 +65,16 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where a > 5;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d
-6 60 600 6000
-7 70 700 7000
-8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -81,19 +84,25 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
+1 SIMPLE t1 index PRIMARY c 5 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -103,13 +112,14 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -120,22 +130,23 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 1050;
a b c d
-8 80 800 8000
-9 90 900 9000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -145,61 +156,76 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
delete from t1 where b > 10 and b < 90;
select * from t1;
a b c d
1 10 100 1000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select * from t1 where a > 5;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select a from t1 where a > 5;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30;
a b
9 90
+10 100
+11 110
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select a,c from t1 where c > 750;
a c
9 900
+10 1000
+11 1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
index a594b10..aa33246 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
@@ -7,22 +7,19 @@ insert into t1 values (2,"20",200);
insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
+explain select * from t1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 3 Using where
-select * from t1 where a > 2;
+1 SIMPLE t1 range a a 5 NULL 2 Using where
+select * from t1 where a > 3;
a b c
-3 30 300
4 40 400
5 50 500
-select b from t1 where a > 2;
+select b from t1 where a > 3;
b
-30
40
50
-select c from t1 where a > 2;
+select c from t1 where a > 3;
c
-300
400
500
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
index fab2880..4c2fc08 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,30 +14,30 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -46,13 +49,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 add index bdca(b,d,c,a) clustering=yes;
insert into t1 values (10,10,10,10);
alter table t1 drop index bdca;
@@ -67,79 +78,73 @@ a b c d
8 80 800 8000
9 90 900 9000
10 10 10 10
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select b from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
alter table t1 add e varchar(20);
alter table t1 add primary key (a,b,c);
-explain select * from t1 where a > 5;
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d e
-6 60 600 6000 NULL
-7 70 700 7000 NULL
-8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select a from t1 where a > 8;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -151,13 +156,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -169,40 +182,38 @@ a b c d e
8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select b from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
index c6754db..6b458b3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
@@ -2,16 +2,16 @@ SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
index 41abded..2dcb65c 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
@@ -32,13 +32,13 @@ max(a)
7
explain select a,b from z1 where a < 7;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 12 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 7;
max(a)
3
explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 3;
max(a)
1
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
index 14ab9a2..586cf2e 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,48 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -63,6 +66,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -74,6 +79,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -81,12 +88,14 @@ select * from t1 where c > 750;
a b c d
8 85 805 8000
9 95 905 9000
-explain select a from t1 where a > 8;
+10 105 1005 10000
+11 115 1105 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NA b b 5 NULL NULL; Using where; Using index
@@ -98,6 +107,8 @@ a b
7 75
8 85
9 95
+10 105
+11 115
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -105,6 +116,8 @@ select a,c from t1 where c > 750;
a c
8 805
9 905
+10 1005
+11 1105
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -115,24 +128,25 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where b > 30;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 45 405 4000
-5 55 505 5000
-6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where c > 750;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 85 805 8000
-9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -142,24 +156,25 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 45
-5 55
-6 65
7 75
8 85
9 95
-explain select a,b from t1 where c > 750;
+10 105
+11 115
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 805
-9 905
+10 1005
+11 1105
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
a b c d
@@ -172,6 +187,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -181,6 +198,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -192,6 +211,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -199,6 +220,8 @@ select * from t1 where c > 750;
a b c d
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -208,6 +231,8 @@ a
7
8
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -219,6 +244,8 @@ a b
7 80
8 90
9 100
+10 110
+11 120
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -226,4 +253,6 @@ select a,c from t1 where c > 750;
a c
8 810
9 910
+10 1010
+11 1110
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
index 2a0ee4f..55a2cc4 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
index 4580cc9..1b5998b 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
index fb998e3..0bba5b7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
index 9d9fb4c..556c5ff 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
index 994b906..f741dca 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
@@ -31,7 +31,7 @@ delete from foo where a > 5;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a > 1;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
index 6bf54ef..37701ef 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
@@ -31,7 +31,7 @@ delete from foo where a < 10;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
index cc2bb45..a404348 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
@@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1 and a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 8 values
select * from foo where a > 1 and a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
index 024580d..fd584a3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
+++ b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
@@ -305,25 +305,25 @@ dummy INT PRIMARY KEY,
a INT UNIQUE,
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
dummy a b
-3 3 3
-5 5 5
+8 8 8
+9 9 9
connection con2;
SET AUTOCOMMIT=0;
SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
connection con1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_bit.result b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
index c147c20..76a032d 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_bit.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort
+1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_blob.result b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
index 1350bc0..3f65967 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_blob.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
@@ -667,14 +667,14 @@ id txt
alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where; Using filesort
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort
select * from t1 where txt='Chevy' or txt is NULL order by txt;
id txt
3 NULL
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
index c2196bf..0cace80 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
@@ -22,7 +22,9 @@ alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d);
alter table t1 add key bar(d,c,b,a) clustering=yes;
show create table t1;
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+ (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+ (32,54,12,56);
explain select * from t1;
select * from t1;
explain select d from t1 where d > 30;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
index 1c0ebad..cb49092 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
@@ -7,8 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
-
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -19,38 +21,38 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 850;
+select * from t1 where c > 850;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
delete from t1 where b>30 and b < 60;
select * from t1;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
@@ -76,8 +78,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
alter table t1 drop primary key;
@@ -88,13 +90,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 1050;
+select * from t1 where c > 1050;
#covering indexes
@@ -105,13 +107,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
delete from t1 where b > 10 and b < 90;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
index 192e56f..dc788d5 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
@@ -13,10 +13,10 @@ insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
-select * from t1 where a > 2;
-select b from t1 where a > 2;
-select c from t1 where a > 2;
+explain select * from t1 where a > 3;
+select * from t1 where a > 3;
+select b from t1 where a > 3;
+select c from t1 where a > 3;
#explain delete from t1 where a <2;
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
index a438653..23207f2 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
@@ -11,18 +11,18 @@ insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
# ignore rows column
--replace_column 9 NULL;
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
index ce5a025..42a004f 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
@@ -7,7 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -19,30 +22,30 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
+explain select a from t1 where a > 10;
select a from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
@@ -64,8 +67,8 @@ select * from t1 where c > 750;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 4 NA 9 NULL;
@@ -86,13 +89,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
@@ -102,13 +105,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
diff --git a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
index 6130933..dcee594 100644
--- a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
+++ b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
@@ -40,16 +40,16 @@ CREATE TABLE t1 (
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
connection con2;
@@ -58,7 +58,7 @@ SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
--error ER_LOCK_WAIT_TIMEOUT
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ROLLBACK;
connection con1;
1
0
revision-id: f1f1b5ce03afeb9a0f6147007b4ce8ac762b65ed (mariadb-10.3.6-108-gf1f1b5c)
parent(s): 9e114455a95c15cd1e37dabef0dff1fe2588d50a
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-02-07 23:48:10 -0800
message:
MDEV-16188 Post merge fixes fot TokuDB
---
sql/handler.h | 2 +
sql/multi_range_read.cc | 19 ++-
storage/tokudb/ha_tokudb.cc | 20 +--
storage/tokudb/ha_tokudb.h | 1 +
.../mysql-test/tokudb/include/cluster_key.inc | 73 ++++-----
.../mysql-test/tokudb/r/cluster_2968-2.result | 2 +-
.../tokudb/r/cluster_create_table.result | 8 +-
.../mysql-test/tokudb/r/cluster_delete.result | 128 +++++++++-------
.../mysql-test/tokudb/r/cluster_filter_key.result | 13 +-
.../tokudb/mysql-test/tokudb/r/cluster_key.result | 165 +++++++++++----------
.../mysql-test/tokudb/r/cluster_query_plan.result | 8 +-
.../tokudb/r/cluster_tokudb_bug_993_2.result | 4 +-
.../mysql-test/tokudb/r/cluster_update.result | 115 ++++++++------
.../mysql-test/tokudb/r/ext_key_1_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_1_tokudb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_innodb.result | 2 +-
.../mysql-test/tokudb/r/ext_key_2_tokudb.result | 2 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-29.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-30.result | 4 +-
storage/tokudb/mysql-test/tokudb/r/mvcc-31.result | 4 +-
.../tokudb/mysql-test/tokudb/r/tokudb_mrr.result | 12 +-
storage/tokudb/mysql-test/tokudb/r/type_bit.result | 2 +-
.../tokudb/mysql-test/tokudb/r/type_blob.result | 4 +-
.../mysql-test/tokudb/t/cluster_create_table.test | 4 +-
.../tokudb/mysql-test/tokudb/t/cluster_delete.test | 52 +++----
.../mysql-test/tokudb/t/cluster_filter_key.test | 8 +-
.../mysql-test/tokudb/t/cluster_query_plan.test | 8 +-
.../tokudb/mysql-test/tokudb/t/cluster_update.test | 43 +++---
storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test | 8 +-
29 files changed, 404 insertions(+), 315 deletions(-)
diff --git a/sql/handler.h b/sql/handler.h
index 0836360..6f44c68 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -4748,6 +4748,8 @@ class handler :public Sql_alloc
virtual void update_partition(uint part_id)
{}
+ virtual bool is_clustering_key(uint index) { return false; }
+
protected:
Handler_share *get_ha_share_ptr();
void set_ha_share_ptr(Handler_share *arg_ha_share);
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index 12f72f5..027d2f7 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -20,10 +20,16 @@
#include "key.h"
#include "sql_statistics.h"
-static ulonglong key_block_no(handler *h, uint keyno, ha_rows keyentry_pos)
+static ulonglong key_block_no(TABLE *table, uint keyno, ha_rows keyentry_pos)
{
- return (ulonglong) (h->keyread_time(keyno, 1, keyentry_pos + 1) -
- h->keyread_time(keyno, 0, keyentry_pos + 1) + 0.5) + 1;
+ size_t len= table->key_info[keyno].key_length + table->file->ref_length;
+ if (keyno == table->s->primary_key &&
+ table->file->primary_key_is_clustered())
+ len= table->s->stored_rec_length;
+ uint keys_per_block= (uint) (table->file->stats.block_size/2.0/len+1);
+ ulonglong block_no= !keyentry_pos ? 0 :
+ (keyentry_pos - 1) / keys_per_block + 1;
+ return block_no;
}
/****************************************************************************
@@ -177,8 +183,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
}
min_pos+= r - rows;
}
- min_block_no= key_block_no(this, keyno, min_pos);
- max_block_no= key_block_no(this, keyno, min_pos + rows);
+ min_block_no= key_block_no(this->table, keyno, min_pos);
+ max_block_no= key_block_no(this->table, keyno, min_pos + rows);
new_touched_blocks= max_block_no - min_block_no +
MY_TEST(min_block_no != prev_max_block_no);
prev_max_block_no= max_block_no;
@@ -202,7 +208,8 @@ handler::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq,
cost->reset();
cost->avg_io_cost= 1; /* assume random seeks */
cost->idx_avg_io_cost= 1;
- if (!(keyno == table->s->primary_key && primary_key_is_clustered()))
+ if (!((keyno == table->s->primary_key && primary_key_is_clustered()) ||
+ is_clustering_key(keyno)))
{
cost->idx_io_count= total_touched_blocks +
keyread_time(keyno, 0, total_rows);
diff --git a/storage/tokudb/ha_tokudb.cc b/storage/tokudb/ha_tokudb.cc
index 4196440..b0f438b 100644
--- a/storage/tokudb/ha_tokudb.cc
+++ b/storage/tokudb/ha_tokudb.cc
@@ -7775,13 +7775,18 @@ double ha_tokudb::scan_time() {
DBUG_RETURN(ret_val);
}
+bool ha_tokudb::is_clustering_key(uint index)
+{
+ return index == primary_key || key_is_clustering(&table->key_info[index]);
+}
+
double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
{
TOKUDB_HANDLER_DBUG_ENTER("%u %u %" PRIu64, index, ranges, (uint64_t) rows);
- double ret_val;
- if (index == primary_key || key_is_clustering(&table->key_info[index])) {
- ret_val = read_time(index, ranges, rows);
- DBUG_RETURN(ret_val);
+ double cost;
+ if (index == primary_key || is_clustering_key(index)) {
+ cost = read_time(index, ranges, rows);
+ DBUG_RETURN(cost);
}
/*
It is assumed that we will read trough the whole key range and that all
@@ -7791,11 +7796,8 @@ double ha_tokudb::keyread_time(uint index, uint ranges, ha_rows rows)
blocks read. This model does not take into account clustered indexes -
engines that support that (e.g. InnoDB) may want to overwrite this method.
*/
- double keys_per_block= (stats.block_size/2.0/
- (table->key_info[index].key_length +
- ref_length) + 1);
- ret_val = (rows + keys_per_block - 1)/ keys_per_block;
- TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(ret_val);
+ cost= handler::keyread_time(index, ranges, rows);
+ TOKUDB_HANDLER_DBUG_RETURN_DOUBLE(cost);
}
//
diff --git a/storage/tokudb/ha_tokudb.h b/storage/tokudb/ha_tokudb.h
index 75fabbf..58121f9 100644
--- a/storage/tokudb/ha_tokudb.h
+++ b/storage/tokudb/ha_tokudb.h
@@ -871,6 +871,7 @@ class ha_tokudb : public handler {
bool primary_key_is_clustered() {
return true;
}
+ bool is_clustering_key(uint index);
int cmp_ref(const uchar * ref1, const uchar * ref2);
bool check_if_incompatible_data(HA_CREATE_INFO * info, uint table_changes);
diff --git a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
index d637b46..b629be0 100644
--- a/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
+++ b/storage/tokudb/mysql-test/tokudb/include/cluster_key.inc
@@ -1,7 +1,10 @@
# test for TokuDB clustering keys.
# test assumes that a table 't1' exists with the following columns:
# a int, b int, c int, d int
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -13,20 +16,20 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -35,8 +38,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 add index bdca(b,d,c,a) clustering=yes;
@@ -51,25 +54,25 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
alter table t1 add e varchar(20);
@@ -77,25 +80,25 @@ alter table t1 add primary key (a,b,c);
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
@@ -104,8 +107,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 350;
+select a,c from t1 where c > 350;
alter table t1 drop primary key;
@@ -116,23 +119,23 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where b > 30;
-select b from t1 where b > 30;
+explain select b from t1 where b > 70;
+select b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select b from t1 where c > 750;
-select c from t1 where c > 750;
+explain select b from t1 where c > 950;
+select c from t1 where c > 950;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
index 4c3f971..b274996 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_2968-2.result
@@ -1096,7 +1096,7 @@ t CREATE TABLE `t` (
explain select straight_join s.a,t.a from s,t where s.b = t.b;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE s index b,b_2,b_3 b_2 10 NULL 1000 Using where; Using index
-1 SIMPLE t ref b,b_2,b_3 b_2 5 test.s.b 1 Using index
+1 SIMPLE t ref b,b_2,b_3 b_3 5 test.s.b 1 Using index
alter table s drop key b_2;
alter table t drop key b_2;
show create table s;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
index 02a90c6..bbc886f 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_create_table.result
@@ -39,16 +39,20 @@ t1 CREATE TABLE `t1` (
KEY `foo` (`c`,`d`) `clustering`=yes,
KEY `bar` (`d`,`c`,`b`,`a`) `clustering`=yes
) ENGINE=TokuDB DEFAULT CHARSET=latin1
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+(1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+(32,54,12,56);
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index NULL PRIMARY 16 NULL 5 Using index
+1 SIMPLE t1 index NULL PRIMARY 16 NULL 7 Using index
select * from t1;
a b c d
1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
+5 5 5 5
+6 6 6 6
32 54 12 56
explain select d from t1 where d > 30;
id select_type table type possible_keys key key_len ref rows Extra
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
index 1fd519d..0c7a67a 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_delete.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,47 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 850;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
+select * from t1 where c > 850;
a b c d
-8 80 800 8000
9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-explain select a,b from t1 where b > 30;
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
delete from t1 where b>30 and b < 60;
select * from t1;
a b c d
@@ -63,15 +65,16 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where a > 5;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d
-6 60 600 6000
-7 70 700 7000
-8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -81,19 +84,25 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range c c 5 NULL NULL; Using where
+1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
8 80 800 8000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
+1 SIMPLE t1 index PRIMARY c 5 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -103,13 +112,14 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -120,22 +130,23 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 1050;
a b c d
-8 80 800 8000
-9 90 900 9000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -145,61 +156,76 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 1050;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 1050;
a c
-8 800
-9 900
+11 1100
delete from t1 where b > 10 and b < 90;
select * from t1;
a b c d
1 10 100 1000
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select * from t1 where a > 5;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select * from t1 where b > 30;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select * from t1 where c > 750;
a b c d
9 90 900 9000
+10 100 1000 10000
+11 110 1100 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
select a from t1 where a > 5;
a
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
select a,b from t1 where b > 30;
a b
9 90
+10 100
+11 110
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
select a,c from t1 where c > 750;
a c
9 900
+10 1000
+11 1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
index a594b10..aa33246 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_filter_key.result
@@ -7,22 +7,19 @@ insert into t1 values (2,"20",200);
insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
+explain select * from t1 where a > 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 5 NULL 3 Using where
-select * from t1 where a > 2;
+1 SIMPLE t1 range a a 5 NULL 2 Using where
+select * from t1 where a > 3;
a b c
-3 30 300
4 40 400
5 50 500
-select b from t1 where a > 2;
+select b from t1 where a > 3;
b
-30
40
50
-select c from t1 where a > 2;
+select c from t1 where a > 3;
c
-300
400
500
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
index fab2880..d83c8bf 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_key.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a,b,c), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,30 +14,30 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -46,13 +49,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 add index bdca(b,d,c,a) clustering=yes;
insert into t1 values (10,10,10,10);
alter table t1 drop index bdca;
@@ -67,79 +78,73 @@ a b c d
8 80 800 8000
9 90 900 9000
10 10 10 10
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select b from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
alter table t1 add e varchar(20);
alter table t1 add primary key (a,b,c);
-explain select * from t1 where a > 5;
+explain select * from t1 where a > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-select * from t1 where a > 5;
+select * from t1 where a > 8;
a b c d e
-6 60 600 6000 NULL
-7 70 700 7000 NULL
-8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select a from t1 where a > 8;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
-10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b c 4 NULL NULL; Using where; Using index
@@ -151,13 +156,21 @@ a b
7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 350;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index c c 4 NULL NULL; Using where; Using index
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 350;
a c
+4 400
+5 500
+6 600
+7 700
8 800
9 900
+10 1000
+11 1100
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -169,40 +182,38 @@ a b c d e
8 80 800 8000 NULL
9 90 900 9000 NULL
10 10 10 10 NULL
-explain select * from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d e
-4 40 400 4000 NULL
-5 50 500 5000 NULL
-6 60 600 6000 NULL
-7 70 700 7000 NULL
8 80 800 8000 NULL
9 90 900 9000 NULL
-explain select * from t1 where c > 750;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d e
-8 80 800 8000 NULL
-9 90 900 9000 NULL
-explain select b from t1 where b > 30;
+10 100 1000 10000 NULL
+11 110 1100 11000 NULL
+explain select b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 4 NULL NULL; Using where; Using index
-select b from t1 where b > 30;
+select b from t1 where b > 70;
b
-40
-50
-60
-70
80
90
-explain select b from t1 where c > 750;
+100
+110
+explain select b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 4 NULL NULL; Using where
-select c from t1 where c > 750;
+select c from t1 where c > 950;
c
-800
-900
+1000
+1100
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
index c6754db..6b458b3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_query_plan.result
@@ -2,16 +2,16 @@ SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),(7,7,7,7),(8,8,8,8),(9,9,9,9);
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
index 41abded..2dcb65c 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_tokudb_bug_993_2.result
@@ -32,13 +32,13 @@ max(a)
7
explain select a,b from z1 where a < 7;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 12 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 7;
max(a)
3
explain select a,b from z1 where a < 3;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE z1 range a a 5 NULL 9 Using where; Using index
+1 SIMPLE z1 index a a 10 NULL 14 Using where; Using index
select max(a) from z1 where a < 3;
max(a)
1
diff --git a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
index 14ab9a2..586cf2e 100644
--- a/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
+++ b/storage/tokudb/mysql-test/tokudb/r/cluster_update.result
@@ -1,7 +1,10 @@
SET DEFAULT_STORAGE_ENGINE='tokudb';
DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+(1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+(9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where
@@ -11,48 +14,48 @@ a b c d
7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where b > 30;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 40 400 4000
-5 50 500 5000
-6 60 600 6000
-7 70 700 7000
8 80 800 8000
9 90 900 9000
-explain select * from t1 where c > 750;
+10 100 1000 10000
+11 110 1100 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 80 800 8000
-9 90 900 9000
-explain select a from t1 where a > 8;
+10 100 1000 10000
+11 110 1100 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
select a from t1 where a > 8;
a
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 40
-5 50
-6 60
-7 70
8 80
9 90
-explain select a,b from t1 where c > 750;
+10 100
+11 110
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 800
-9 900
+10 1000
+11 1100
update t1 set c = c+5, b = b+5 where b>30;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -63,6 +66,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -74,6 +79,8 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -81,12 +88,14 @@ select * from t1 where c > 750;
a b c d
8 85 805 8000
9 95 905 9000
-explain select a from t1 where a > 8;
+10 105 1005 10000
+11 115 1105 11000
+explain select a from t1 where a > 10;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL NULL; Using where; Using index
-select a from t1 where a > 8;
+select a from t1 where a > 10;
a
-9
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 NA b b 5 NULL NULL; Using where; Using index
@@ -98,6 +107,8 @@ a b
7 75
8 85
9 95
+10 105
+11 115
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -105,6 +116,8 @@ select a,c from t1 where c > 750;
a c
8 805
9 905
+10 1005
+11 1105
alter table t1 drop primary key;
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
@@ -115,24 +128,25 @@ a b c d
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where b > 30;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select * from t1 where b > 30;
+select * from t1 where b > 70;
a b c d
-4 45 405 4000
-5 55 505 5000
-6 65 605 6000
7 75 705 7000
8 85 805 8000
9 95 905 9000
-explain select * from t1 where c > 750;
+10 105 1005 10000
+11 115 1105 11000
+explain select * from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select * from t1 where c > 750;
+select * from t1 where c > 950;
a b c d
-8 85 805 8000
-9 95 905 9000
+10 105 1005 10000
+11 115 1105 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -142,24 +156,25 @@ a
7
8
9
-explain select a,b from t1 where b > 30;
+10
+11
+explain select a,b from t1 where b > 70;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range b b 5 NULL NULL; Using where; Using index
-select a,b from t1 where b > 30;
+select a,b from t1 where b > 70;
a b
-4 45
-5 55
-6 65
7 75
8 85
9 95
-explain select a,b from t1 where c > 750;
+10 105
+11 115
+explain select a,b from t1 where c > 950;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range c c 5 NULL NULL; Using where
-select a,c from t1 where c > 750;
+select a,c from t1 where c > 950;
a c
-8 805
-9 905
+10 1005
+11 1105
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
a b c d
@@ -172,6 +187,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -181,6 +198,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -192,6 +211,8 @@ a b c d
7 80 710 7000
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select * from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -199,6 +220,8 @@ select * from t1 where c > 750;
a b c d
8 90 810 8000
9 100 910 9000
+10 110 1010 10000
+11 120 1110 11000
explain select a from t1 where a > 5;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL NULL; Using where
@@ -208,6 +231,8 @@ a
7
8
9
+10
+11
explain select a,b from t1 where b > 30;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index b b 5 NULL NULL; Using where; Using index
@@ -219,6 +244,8 @@ a b
7 80
8 90
9 100
+10 110
+11 120
explain select a,b from t1 where c > 750;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL c NULL NULL NULL NULL; Using where
@@ -226,4 +253,6 @@ select a,c from t1 where c > 750;
a c
8 810
9 910
+10 1010
+11 1110
drop table t1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
index 2a0ee4f..55a2cc4 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=innodb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
index 4580cc9..1b5998b 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_1_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (id int not null, x int not null, y int not null, primary key(id), key(x)) engine=tokudb;
insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4);
explain select x,id from t force index (x) where x=0 and id=0;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
index fb998e3..0bba5b7 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_innodb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=innodb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
index 9d9fb4c..556c5ff 100644
--- a/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
+++ b/storage/tokudb/mysql-test/tokudb/r/ext_key_2_tokudb.result
@@ -1,7 +1,7 @@
drop table if exists t;
select @@optimizer_switch;
@@optimizer_switch
-index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on
+index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on
create table t (a int not null, b int not null, c int not null, d int not null, primary key(a,b), key(c,a)) engine=tokudb;
insert into t values (0,0,0,0),(0,1,0,1);
explain select c,a,b from t where c=0 and a=0 and b=1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
index 994b906..f741dca 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-29.result
@@ -31,7 +31,7 @@ delete from foo where a > 5;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a > 1;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a > 1;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
index 6bf54ef..37701ef 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-30.result
@@ -31,7 +31,7 @@ delete from foo where a < 10;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 9
explain select * from foo where a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 9 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 9 values
select * From foo where a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
index cc2bb45..a404348 100644
--- a/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
+++ b/storage/tokudb/mysql-test/tokudb/r/mvcc-31.result
@@ -31,7 +31,7 @@ delete from foo where a = 2 or a = 4 or a = 10 or a = 30 or a = 50;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# should have just 4 values
select * from foo where a > 1 and a < 50;
a b
@@ -43,7 +43,7 @@ connection conn1;
# number of rows should be 8
explain select * from foo where a > 1 and a < 50;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 8 Using where
+1 SIMPLE foo range PRIMARY PRIMARY 4 NULL 5 Using where
# 8 values
select * from foo where a > 1 and a < 50;
a b
diff --git a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
index 024580d..fd584a3 100644
--- a/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
+++ b/storage/tokudb/mysql-test/tokudb/r/tokudb_mrr.result
@@ -305,25 +305,25 @@ dummy INT PRIMARY KEY,
a INT UNIQUE,
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 range a a 5 NULL 2 Using where
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
dummy a b
-3 3 3
-5 5 5
+8 8 8
+9 9 9
connection con2;
SET AUTOCOMMIT=0;
SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
ROLLBACK;
connection con1;
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_bit.result b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
index c147c20..76a032d 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_bit.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_bit.result
@@ -759,7 +759,7 @@ CREATE TABLE t1 (a BIT(7), b BIT(9), KEY(a, b));
INSERT INTO t1 VALUES(0, 0), (5, 3), (5, 6), (6, 4), (7, 0);
EXPLAIN SELECT a+0, b+0 FROM t1 WHERE a > 4 and b < 7 ORDER BY 2;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 range a a 2 NULL 4 Using where; Using index; Using filesort
+1 SIMPLE t1 index a a 5 NULL 5 Using where; Using index; Using filesort
DROP TABLE t1;
End of 5.0 tests
create table t1(a bit(7));
diff --git a/storage/tokudb/mysql-test/tokudb/r/type_blob.result b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
index 1350bc0..3f65967 100644
--- a/storage/tokudb/mysql-test/tokudb/r/type_blob.result
+++ b/storage/tokudb/mysql-test/tokudb/r/type_blob.result
@@ -667,14 +667,14 @@ id txt
alter table t1 modify column txt blob;
explain select * from t1 where txt='Chevy' or txt is NULL;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where
select * from t1 where txt='Chevy' or txt is NULL;
id txt
1 Chevy
3 NULL
explain select * from t1 where txt='Chevy' or txt is NULL order by txt;
id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL txt_index NULL NULL NULL 4 Using where; Using filesort
+1 SIMPLE t1 ref_or_null txt_index txt_index 23 const 2 Using where; Using filesort
select * from t1 where txt='Chevy' or txt is NULL order by txt;
id txt
3 NULL
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
index c2196bf..0cace80 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_create_table.test
@@ -22,7 +22,9 @@ alter table t1 drop primary key;
alter table t1 add primary key (a,b,c,d);
alter table t1 add key bar(d,c,b,a) clustering=yes;
show create table t1;
-insert into t1 value (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(32,54,12,56);
+insert into t1 value
+ (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6),
+ (32,54,12,56);
explain select * from t1;
select * from t1;
explain select d from t1 where d > 30;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
index 1c0ebad..3963252 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_delete.test
@@ -7,9 +7,11 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
-
-
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
+
#normal queries
# ignore rows column
@@ -19,38 +21,38 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 850;
+select * from t1 where c > 850;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
delete from t1 where b>30 and b < 60;
select * from t1;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 5;
-select * from t1 where a > 5;
+explain select * from t1 where a > 8;
+select * from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
@@ -76,8 +78,8 @@ select a,b from t1 where b > 30;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
alter table t1 drop primary key;
@@ -88,13 +90,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 1050;
+select * from t1 where c > 1050;
#covering indexes
@@ -105,13 +107,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 1050;
+select a,c from t1 where c > 1050;
delete from t1 where b > 10 and b < 90;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
index 192e56f..dc788d5 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_filter_key.test
@@ -13,10 +13,10 @@ insert into t1 values (3,"30",300);
insert into t1 values (4,"40",400);
insert into t1 values (5,"50",500);
-explain select * from t1 where a > 2;
-select * from t1 where a > 2;
-select b from t1 where a > 2;
-select c from t1 where a > 2;
+explain select * from t1 where a > 3;
+select * from t1 where a > 3;
+select b from t1 where a > 3;
+select c from t1 where a > 3;
#explain delete from t1 where a <2;
delete from t1 where a <2;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
index a438653..23207f2 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_query_plan.test
@@ -11,18 +11,18 @@ insert into t1 values (1,1,1,1),(2,2,2,2),(3,3,3,3),(4,4,4,4),(5,5,5,5),(6,6,6,6
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 2;
+explain select * from t1 where b > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 2;
+explain select * from t1 where c > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where a > 4;
+explain select * from t1 where a > 7;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 7;
+explain select * from t1 where c > 8;
# ignore rows column
--replace_column 9 NULL;
explain select * from t1 where b > 7;
diff --git a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
index ce5a025..42a004f 100644
--- a/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
+++ b/storage/tokudb/mysql-test/tokudb/t/cluster_update.test
@@ -7,7 +7,10 @@ DROP TABLE IF EXISTS t1;
create table t1(a int, b int, c int, d int, primary key(a), key(b) clustering=yes, key (c))engine=tokudb;
-insert into t1 values (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),(5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),(9,90,900,9000);
+insert into t1 values
+ (1,10,100,1000),(2,20,200,2000),(3,30,300,3000),(4,40,400,4000),
+ (5,50,500,5000),(6,60,600,6000),(7,70,700,7000),(8,80,800,8000),
+ (9,90,900,9000),(10,100,1000,10000),(11,110,1100,11000);
#normal queries
@@ -19,30 +22,30 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
+explain select a from t1 where a > 10;
select a from t1 where a > 8;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
@@ -64,8 +67,8 @@ select * from t1 where c > 750;
#covering indexes
# ignore rows column
--replace_column 9 NULL;
-explain select a from t1 where a > 8;
-select a from t1 where a > 8;
+explain select a from t1 where a > 10;
+select a from t1 where a > 10;
# ignore rows column
--replace_column 4 NA 9 NULL;
@@ -86,13 +89,13 @@ select * from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where b > 30;
-select * from t1 where b > 30;
+explain select * from t1 where b > 70;
+select * from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select * from t1 where c > 750;
-select * from t1 where c > 750;
+explain select * from t1 where c > 950;
+select * from t1 where c > 950;
#covering indexes
# ignore rows column
@@ -102,13 +105,13 @@ select a from t1 where a > 5;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where b > 30;
-select a,b from t1 where b > 30;
+explain select a,b from t1 where b > 70;
+select a,b from t1 where b > 70;
# ignore rows column
--replace_column 9 NULL;
-explain select a,b from t1 where c > 750;
-select a,c from t1 where c > 750;
+explain select a,b from t1 where c > 950;
+select a,c from t1 where c > 950;
update t1 set c = c+5, b = b+5 where b>30;
select * from t1;
diff --git a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
index 6130933..dcee594 100644
--- a/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
+++ b/storage/tokudb/mysql-test/tokudb/t/tokudb_mrr.test
@@ -40,16 +40,16 @@ CREATE TABLE t1 (
b INT
) ENGINE=TokuDB;
-INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5);
+INSERT INTO t1 VALUES (1,1,1),(3,3,3),(5,5,5),(7,7,7),(8,8,8),(9,9,9);
COMMIT;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
START TRANSACTION;
-EXPLAIN SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+EXPLAIN SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
-SELECT * FROM t1 WHERE a >= 2 FOR UPDATE;
+SELECT * FROM t1 WHERE a >= 8 FOR UPDATE;
connection con2;
@@ -58,7 +58,7 @@ SET TOKUDB_LOCK_TIMEOUT=2;
START TRANSACTION;
--error ER_LOCK_WAIT_TIMEOUT
-INSERT INTO t1 VALUES (2,2,2);
+INSERT INTO t1 VALUES (8,8,8);
ROLLBACK;
connection con1;
1
0