Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

Commit da81ffd

Browse files
Jupyung Lee (JP)Herman Lee
authored andcommitted
[bypass] support multiple conditions for the same field
Summary: Today, bypass engine supports 2 conditions with lower/upper bound, like "where a >= 3 and a <= 5", but doesn't support multiple conditions for the same field like "a >= 3 and a >= 5" or "a <= 3 and a <= 5". Let's support these conditions by skipping unnecessary conditions (eg. skipping a >=3 with the presence of a >= 5, skipping a <= 5 with the presence of a <= 3) Reviewed By: luqun Differential Revision: D43900214
1 parent 672edf0 commit da81ffd

10 files changed

Lines changed: 684 additions & 288 deletions

‎mysql-test/suite/rocksdb/r/bypass_rpc_scenarios.result‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,23 @@ Warning 1681 Integer display width is deprecated and will be removed in a future
133133
Warning 1681 Integer display width is deprecated and will be removed in a future release.
134134
Warning 1681 Integer display width is deprecated and will be removed in a future release.
135135
Warning 1681 Integer display width is deprecated and will be removed in a future release.
136+
CREATE TABLE `time_range` (
137+
`id1` bigint unsigned NOT NULL DEFAULT '0' ,
138+
`id1_type` int unsigned NOT NULL DEFAULT '0' ,
139+
`id2` bigint unsigned NOT NULL DEFAULT '0' ,
140+
`id2_type` int unsigned NOT NULL DEFAULT '0' ,
141+
`link_type` bigint unsigned NOT NULL DEFAULT '0' ,
142+
`time` int unsigned NOT NULL DEFAULT '0' ,
143+
PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
144+
KEY `id1_type` (`id1`,`link_type`,`time`,`id2`)
145+
COMMENT 'rev:cf_link_id1_type'
146+
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
147+
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
148+
INSERT INTO time_range VALUES (100, 10, 200, 20, 1000, 1);
149+
INSERT INTO time_range VALUES (100, 10, 201, 21, 1000, 2);
150+
INSERT INTO time_range VALUES (100, 10, 202, 22, 1000, 3);
151+
INSERT INTO time_range VALUES (100, 10, 203, 23, 1000, 4);
152+
INSERT INTO time_range VALUES (100, 10, 204, 24, 1000, 5);
136153
SELECT @@rocksdb_bypass_rpc_on INTO @save_rocksdb_bypass_rpc_on;
137154
set global rocksdb_bypass_rpc_on=1;
138155
INSTALL PLUGIN test_bypass_rpc_plugin_info SONAME 'TEST_BYPASS_RPC_PLUGIN';
@@ -142,4 +159,5 @@ DROP TABLE link_table7;
142159
DROP TABLE link_table8;
143160
DROP TABLE meta_table;
144161
DROP TABLE obj_info;
162+
DROP TABLE time_range;
145163
set global rocksdb_bypass_rpc_on=@save_rocksdb_bypass_rpc_on;

‎mysql-test/suite/rocksdb/r/bypass_rpc_unsupported.result‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ SELECT @queries_executed_1 - @queries_executed_0;
4242
0
4343
SELECT @queries_failed_1 - @queries_failed_0;
4444
@queries_failed_1 - @queries_failed_0
45-
14
45+
9
4646
SELECT @queries_rejected_1 - @queries_rejected_0;
4747
@queries_rejected_1 - @queries_rejected_0
48-
26
48+
21
4949
SELECT @@rocksdb_select_bypass_rejected_query_history_size into @save_rocksdb_select_bypass_rejected_query_history_size;
5050
SELECT @@rocksdb_bypass_rpc_rejected_log_ts_interval_secs into @save_rocksdb_bypass_rpc_rejected_log_ts_interval_secs;
5151
set global rocksdb_select_bypass_rejected_query_history_size=4;
@@ -72,16 +72,16 @@ SELECT @queries_executed_2 - @queries_executed_0;
7272
0
7373
SELECT @queries_failed_2 - @queries_failed_0;
7474
@queries_failed_2 - @queries_failed_0
75-
17
75+
11
7676
SELECT @queries_rejected_2 - @queries_rejected_0;
7777
@queries_rejected_2 - @queries_rejected_0
78-
29
78+
23
7979
SELECT QUERY, ERROR_MSG, BYPASS_TYPE from information_schema.ROCKSDB_BYPASS_REJECTED_QUERY_HISTORY;
8080
QUERY ERROR_MSG BYPASS_TYPE
8181
SELECT /* bypass rpc */ d FROM test.t1 FORCE INDEX (a) WHERE a=1 AND b>2 AND d>4 Non-optimal queries with filters are not allowed RPC
8282
SELECT /* bypass rpc */ d FROM test.t1 FORCE INDEX (a) WHERE a=1 AND b=2 AND d>4 Non-optimal queries with filters are not allowed RPC
83-
SELECT /* bypass rpc */ pk FROM test.t1 WHERE pk>1 AND pk>2 AND pk>3 Unsupported range query pattern RPC
8483
SELECT `d` FROM `test` . `t1` FORCE INDEX ( `a` ) WHERE `a` = ? AND `b` > ? AND `d` > ? Non-optimal queries with filters are not allowed SQL
84+
SELECT `d` FROM `test` . `t1` FORCE INDEX ( `a` ) WHERE `a` = ? AND `b` = ? AND `d` > ? Non-optimal queries with filters are not allowed SQL
8585
set global rocksdb_bypass_rpc_rejected_log_ts_interval_secs=999;
8686
SELECT @@rocksdb_bypass_rpc_rejected_log_ts_interval_secs;
8787
@@rocksdb_bypass_rpc_rejected_log_ts_interval_secs
@@ -99,16 +99,16 @@ SELECT @queries_executed_3 - @queries_executed_0;
9999
0
100100
SELECT @queries_failed_3 - @queries_failed_0;
101101
@queries_failed_3 - @queries_failed_0
102-
20
102+
13
103103
SELECT @queries_rejected_3 - @queries_rejected_0;
104104
@queries_rejected_3 - @queries_rejected_0
105-
32
105+
25
106106
SELECT QUERY, ERROR_MSG, BYPASS_TYPE from information_schema.ROCKSDB_BYPASS_REJECTED_QUERY_HISTORY;
107107
QUERY ERROR_MSG BYPASS_TYPE
108108
SELECT `d` FROM `test` . `t1` FORCE INDEX ( `a` ) WHERE `a` = ? AND `b` > ? AND `d` > ? Non-optimal queries with filters are not allowed SQL
109109
SELECT `d` FROM `test` . `t1` FORCE INDEX ( `a` ) WHERE `a` = ? AND `b` = ? AND `d` > ? Non-optimal queries with filters are not allowed SQL
110-
SELECT `pk` FROM `test` . `t1` WHERE `pk` > ? AND `pk` > ? AND `pk` > ? Unsupported range query pattern SQL
111110
SELECT /* bypass rpc */ d FROM test.t1 FORCE INDEX (a) WHERE a=1 AND b>2 AND d>4 Non-optimal queries with filters are not allowed RPC
111+
SELECT /* bypass rpc */ d FROM test.t1 FORCE INDEX (a) WHERE a=1 AND b=2 AND d>4 Non-optimal queries with filters are not allowed RPC
112112
set global rocksdb_bypass_rpc_on=@save_rocksdb_bypass_rpc_on;
113113
set global rocksdb_bypass_rpc_log_rejected=@save_rocksdb_bypass_rpc_log_rejected;
114114
set global rocksdb_select_bypass_rejected_query_history_size=@save_rocksdb_select_bypass_rejected_query_history_size;

‎mysql-test/suite/rocksdb/r/bypass_select_scenarios.result‎

Lines changed: 209 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,23 @@ INSERT INTO meta_table VALUES (100, 0, 4, 0, 'data4', 1, 2, 3, 'context4',
13381338
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
13391339
INSERT INTO meta_table VALUES (101, 0, 1, 0, 'data1', 1, 2, 3, 'context1',
13401340
1, 0x1, 1, 1, 1, 1, 1, 0, 0);
1341+
CREATE TABLE `time_range` (
1342+
`id1` bigint unsigned NOT NULL DEFAULT '0' ,
1343+
`id1_type` int unsigned NOT NULL DEFAULT '0' ,
1344+
`id2` bigint unsigned NOT NULL DEFAULT '0' ,
1345+
`id2_type` int unsigned NOT NULL DEFAULT '0' ,
1346+
`link_type` bigint unsigned NOT NULL DEFAULT '0' ,
1347+
`time` int unsigned NOT NULL DEFAULT '0' ,
1348+
PRIMARY KEY (`link_type` , `id1` , `id2`) COMMENT 'cf_link' ,
1349+
KEY `id1_type` (`id1`,`link_type`,`time`,`id2`)
1350+
COMMENT 'rev:cf_link_id1_type'
1351+
) ENGINE=ROCKSDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin
1352+
ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8;
1353+
INSERT INTO time_range VALUES (100, 10, 200, 20, 1000, 1);
1354+
INSERT INTO time_range VALUES (100, 10, 201, 21, 1000, 2);
1355+
INSERT INTO time_range VALUES (100, 10, 202, 22, 1000, 3);
1356+
INSERT INTO time_range VALUES (100, 10, 203, 23, 1000, 4);
1357+
INSERT INTO time_range VALUES (100, 10, 204, 24, 1000, 5);
13411358
========== Verifying Bypass Query ==========
13421359
WITH BYPASS:
13431360
SELECT /*+ bypass */ `mt_object_state`, `id`, `mt_object_cookie`,
@@ -1468,6 +1485,197 @@ id2 version data
14681485
include/assert.inc [Verify not executed in bypass]
14691486
include/assert.inc [Verify bypass and regular query return same number of rows]
14701487
include/assert.inc [Verify bypass reads no more than regular query]
1488+
========== Verifying Bypass Query ==========
1489+
WITH BYPASS:
1490+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1491+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=1 AND time>=2 AND time>=3
1492+
ORDER BY time ASC, id2 ASC limit 0,1000;
1493+
id1 id2 link_type time
1494+
100 202 1000 3
1495+
100 203 1000 4
1496+
100 204 1000 5
1497+
ROWS_READ
1498+
3
1499+
COVERED_SK_LOOKUP
1500+
3
1501+
include/assert.inc [Verify executed in bypass]
1502+
WITHOUT BYPASS:
1503+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1504+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=1 AND time>=2 AND time>=3
1505+
ORDER BY time ASC, id2 ASC limit 0,1000;
1506+
id1 id2 link_type time
1507+
100 202 1000 3
1508+
100 203 1000 4
1509+
100 204 1000 5
1510+
include/assert.inc [Verify not executed in bypass]
1511+
include/assert.inc [Verify bypass and regular query return same number of rows]
1512+
include/assert.inc [Verify bypass reads no more than regular query]
1513+
========== Verifying Bypass Query ==========
1514+
WITH BYPASS:
1515+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1516+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=2 AND time>=1 AND time>=3
1517+
ORDER BY time ASC, id2 ASC limit 0,1000;
1518+
id1 id2 link_type time
1519+
100 202 1000 3
1520+
100 203 1000 4
1521+
100 204 1000 5
1522+
ROWS_READ
1523+
3
1524+
COVERED_SK_LOOKUP
1525+
3
1526+
include/assert.inc [Verify executed in bypass]
1527+
WITHOUT BYPASS:
1528+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1529+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=2 AND time>=1 AND time>=3
1530+
ORDER BY time ASC, id2 ASC limit 0,1000;
1531+
id1 id2 link_type time
1532+
100 202 1000 3
1533+
100 203 1000 4
1534+
100 204 1000 5
1535+
include/assert.inc [Verify not executed in bypass]
1536+
include/assert.inc [Verify bypass and regular query return same number of rows]
1537+
include/assert.inc [Verify bypass reads no more than regular query]
1538+
========== Verifying Bypass Query ==========
1539+
WITH BYPASS:
1540+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1541+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=3 AND time>=2 AND time>=1
1542+
ORDER BY time ASC, id2 ASC limit 0,1000;
1543+
id1 id2 link_type time
1544+
100 202 1000 3
1545+
100 203 1000 4
1546+
100 204 1000 5
1547+
ROWS_READ
1548+
3
1549+
COVERED_SK_LOOKUP
1550+
3
1551+
include/assert.inc [Verify executed in bypass]
1552+
WITHOUT BYPASS:
1553+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1554+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=3 AND time>=2 AND time>=1
1555+
ORDER BY time ASC, id2 ASC limit 0,1000;
1556+
id1 id2 link_type time
1557+
100 202 1000 3
1558+
100 203 1000 4
1559+
100 204 1000 5
1560+
include/assert.inc [Verify not executed in bypass]
1561+
include/assert.inc [Verify bypass and regular query return same number of rows]
1562+
include/assert.inc [Verify bypass reads no more than regular query]
1563+
========== Verifying Bypass Query ==========
1564+
WITH BYPASS:
1565+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1566+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=3 AND time<=4 AND time<=5
1567+
ORDER BY time ASC, id2 ASC limit 0,1000;
1568+
id1 id2 link_type time
1569+
100 200 1000 1
1570+
100 201 1000 2
1571+
100 202 1000 3
1572+
ROWS_READ
1573+
3
1574+
COVERED_SK_LOOKUP
1575+
3
1576+
include/assert.inc [Verify executed in bypass]
1577+
WITHOUT BYPASS:
1578+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1579+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=3 AND time<=4 AND time<=5
1580+
ORDER BY time ASC, id2 ASC limit 0,1000;
1581+
id1 id2 link_type time
1582+
100 200 1000 1
1583+
100 201 1000 2
1584+
100 202 1000 3
1585+
include/assert.inc [Verify not executed in bypass]
1586+
include/assert.inc [Verify bypass and regular query return same number of rows]
1587+
include/assert.inc [Verify bypass reads no more than regular query]
1588+
========== Verifying Bypass Query ==========
1589+
WITH BYPASS:
1590+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1591+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=4 AND time<=3 AND time<=5
1592+
ORDER BY time ASC, id2 ASC limit 0,1000;
1593+
id1 id2 link_type time
1594+
100 200 1000 1
1595+
100 201 1000 2
1596+
100 202 1000 3
1597+
ROWS_READ
1598+
3
1599+
COVERED_SK_LOOKUP
1600+
3
1601+
include/assert.inc [Verify executed in bypass]
1602+
WITHOUT BYPASS:
1603+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1604+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=4 AND time<=3 AND time<=5
1605+
ORDER BY time ASC, id2 ASC limit 0,1000;
1606+
id1 id2 link_type time
1607+
100 200 1000 1
1608+
100 201 1000 2
1609+
100 202 1000 3
1610+
include/assert.inc [Verify not executed in bypass]
1611+
include/assert.inc [Verify bypass and regular query return same number of rows]
1612+
include/assert.inc [Verify bypass reads no more than regular query]
1613+
========== Verifying Bypass Query ==========
1614+
WITH BYPASS:
1615+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1616+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=5 AND time<=4 AND time<=3
1617+
ORDER BY time ASC, id2 ASC limit 0,1000;
1618+
id1 id2 link_type time
1619+
ROWS_READ
1620+
0
1621+
COVERED_SK_LOOKUP
1622+
0
1623+
include/assert.inc [Verify executed in bypass]
1624+
WITHOUT BYPASS:
1625+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1626+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=5 AND time<=4 AND time<=3
1627+
ORDER BY time ASC, id2 ASC limit 0,1000;
1628+
id1 id2 link_type time
1629+
include/assert.inc [Verify not executed in bypass]
1630+
include/assert.inc [Verify bypass and regular query return same number of rows]
1631+
include/assert.inc [Verify bypass reads no more than regular query]
1632+
========== Verifying Bypass Query ==========
1633+
WITH BYPASS:
1634+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1635+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=1 AND time>=3 AND
1636+
time<=5 AND time<=4 ORDER BY time ASC, id2 ASC limit 0,1000;
1637+
id1 id2 link_type time
1638+
100 202 1000 3
1639+
100 203 1000 4
1640+
ROWS_READ
1641+
2
1642+
COVERED_SK_LOOKUP
1643+
2
1644+
include/assert.inc [Verify executed in bypass]
1645+
WITHOUT BYPASS:
1646+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1647+
(id1_type) WHERE link_type=1000 AND id1=100 AND time>=1 AND time>=3 AND
1648+
time<=5 AND time<=4 ORDER BY time ASC, id2 ASC limit 0,1000;
1649+
id1 id2 link_type time
1650+
100 202 1000 3
1651+
100 203 1000 4
1652+
include/assert.inc [Verify not executed in bypass]
1653+
include/assert.inc [Verify bypass and regular query return same number of rows]
1654+
include/assert.inc [Verify bypass reads no more than regular query]
1655+
========== Verifying Bypass Query ==========
1656+
WITH BYPASS:
1657+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1658+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=5 AND time>=3 AND
1659+
time<=4 AND time>=1 ORDER BY time ASC, id2 ASC limit 0,1000;
1660+
id1 id2 link_type time
1661+
100 202 1000 3
1662+
100 203 1000 4
1663+
ROWS_READ
1664+
2
1665+
COVERED_SK_LOOKUP
1666+
2
1667+
include/assert.inc [Verify executed in bypass]
1668+
WITHOUT BYPASS:
1669+
SELECT /*+ bypass */ id1,id2,link_type,time FROM time_range FORCE INDEX
1670+
(id1_type) WHERE link_type=1000 AND id1=100 AND time<=5 AND time>=3 AND
1671+
time<=4 AND time>=1 ORDER BY time ASC, id2 ASC limit 0,1000;
1672+
id1 id2 link_type time
1673+
100 202 1000 3
1674+
100 203 1000 4
1675+
include/assert.inc [Verify not executed in bypass]
1676+
include/assert.inc [Verify bypass and regular query return same number of rows]
1677+
include/assert.inc [Verify bypass reads no more than regular query]
1678+
DROP TABLE time_range;
14711679
# Establish connection con1 (user=root)
14721680
# Switch to connection con1
14731681
========== Verifying Bypass Query ==========
@@ -1506,4 +1714,4 @@ FROM performance_schema.global_status WHERE
15061714
variable_name="rocksdb_select_bypass_executed";
15071715
SELECT @executed_end-@executed_start AS ROCKSDB_SELECT_BYPASS_EXECUTED;
15081716
ROCKSDB_SELECT_BYPASS_EXECUTED
1509-
52
1717+
60

0 commit comments

Comments
 (0)