Skip to content

Commit

Permalink
Fix rows_read and queries_range stats in bypass
Browse files Browse the repository at this point in the history
Summary: Bypass updates rows_sent and rows_examined but didn't update rows_read. This fixes that and adds tests. We also get rocksdb_queries_point and rocksdb_queries_range for free as we are using MyRocks API to access data. Note I didn't include rows_examined in the test because querying unrelated information_schema tables will affect rows_examined and it is kinda flaky depending on many factors like perf schema. I did found a double counting issue with rocksdb_queries_range and fixed it as well.

Reviewed By: hermanlee

Differential Revision: D25785830

fbshipit-source-id: 0b3ffb206be
  • Loading branch information
yizhang82 authored and facebook-github-bot committed Jan 6, 2021
1 parent 72c6314 commit 6106eba
Show file tree
Hide file tree
Showing 6 changed files with 489 additions and 7 deletions.
174 changes: 174 additions & 0 deletions mysql-test/suite/rocksdb/r/bypass_select_basic.result
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,180 @@ variable_name="rocksdb_select_bypass_executed";
SELECT @c-@b;
@c-@b
3
# Point Query Stats
SELECT variable_value INTO @bypass_executed_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_old FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_old FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1=1 AND id2=2 AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1 IN (1) AND id2 IN (2) AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1 IN (1, 2) AND id2 IN (2, 3, 4) AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
1 3 1 2 a11 125
1 4 1 2 a11 125
2 2 1 2 a10 125
2 3 1 2 a11 125
2 4 1 2 a11 125
SELECT variable_value INTO @bypass_executed_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_new FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_new FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT @bypass_executed_new - @bypass_executed_old;
@bypass_executed_new - @bypass_executed_old
3
SELECT @bypass_rows_read_new - @bypass_rows_read_old;
@bypass_rows_read_new - @bypass_rows_read_old
8
SELECT @bypass_rows_read_stat_new - @bypass_rows_read_stat_old;
@bypass_rows_read_stat_new - @bypass_rows_read_stat_old
8
SELECT @bypass_queries_point_new - @bypass_queries_point_old;
@bypass_queries_point_new - @bypass_queries_point_old
8
SELECT @bypass_queries_range_new - @bypass_queries_range_old;
@bypass_queries_range_new - @bypass_queries_range_old
0
SELECT @bypass_rows_sent_new - @bypass_rows_sent_old;
@bypass_rows_sent_new - @bypass_rows_sent_old
8
# Range Query Stats
SELECT variable_value INTO @bypass_executed_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_old FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_old FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
1 4 3 4 a11 11 125
1 3 3 4 a11 11 125
1 1 3 4 a10 10 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 10;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
1 4 3 4 a11 11 125
1 3 3 4 a11 11 125
1 1 3 4 a10 10 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 5;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 1;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 0;
id1 id2 link_type visibility data time version
SELECT variable_value INTO @bypass_executed_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_new FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_new FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT @bypass_executed_new - @bypass_executed_old;
@bypass_executed_new - @bypass_executed_old
5
SELECT @bypass_rows_read_new - @bypass_rows_read_old;
@bypass_rows_read_new - @bypass_rows_read_old
23
SELECT @bypass_rows_read_stat_new - @bypass_rows_read_stat_old;
@bypass_rows_read_stat_new - @bypass_rows_read_stat_old
23
SELECT @bypass_queries_point_new - @bypass_queries_point_old;
@bypass_queries_point_new - @bypass_queries_point_old
0
SELECT @bypass_queries_range_new - @bypass_queries_range_old;
@bypass_queries_range_new - @bypass_queries_range_old
5
SELECT @bypass_rows_sent_new - @bypass_rows_sent_old;
@bypass_rows_sent_new - @bypass_rows_sent_old
22
# Point query
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1=1 AND id2=2 AND link_type=3;
Expand Down
174 changes: 174 additions & 0 deletions mysql-test/suite/rocksdb/r/bypass_select_basic_bloom.result
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,180 @@ variable_name="rocksdb_select_bypass_executed";
SELECT @c-@b;
@c-@b
3
# Point Query Stats
SELECT variable_value INTO @bypass_executed_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_old FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_old FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1=1 AND id2=2 AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1 IN (1) AND id2 IN (2) AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1 IN (1, 2) AND id2 IN (2, 3, 4) AND link_type=3;
id1 id2 id1_type id2_type data version
1 2 1 2 a10 125
1 3 1 2 a11 125
1 4 1 2 a11 125
2 2 1 2 a10 125
2 3 1 2 a11 125
2 4 1 2 a11 125
SELECT variable_value INTO @bypass_executed_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_new FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_new FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT @bypass_executed_new - @bypass_executed_old;
@bypass_executed_new - @bypass_executed_old
3
SELECT @bypass_rows_read_new - @bypass_rows_read_old;
@bypass_rows_read_new - @bypass_rows_read_old
8
SELECT @bypass_rows_read_stat_new - @bypass_rows_read_stat_old;
@bypass_rows_read_stat_new - @bypass_rows_read_stat_old
8
SELECT @bypass_queries_point_new - @bypass_queries_point_old;
@bypass_queries_point_new - @bypass_queries_point_old
8
SELECT @bypass_queries_range_new - @bypass_queries_range_old;
@bypass_queries_range_new - @bypass_queries_range_old
0
SELECT @bypass_rows_sent_new - @bypass_rows_sent_old;
@bypass_rows_sent_new - @bypass_rows_sent_old
8
# Range Query Stats
SELECT variable_value INTO @bypass_executed_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_old FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_old FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_old FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
1 4 3 4 a11 11 125
1 3 3 4 a11 11 125
1 1 3 4 a10 10 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 10;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
1 4 3 4 a11 11 125
1 3 3 4 a11 11 125
1 1 3 4 a10 10 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 5;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
1 9 3 4 a14 14 125
1 8 3 4 a13 13 125
1 7 3 4 a12 12 125
1 6 3 4 a12 12 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 1;
id1 id2 link_type visibility data time version
1 10 3 4 a15 15 125
SELECT /*+ bypass */ id1, id2, link_type, visibility, data, time, version
FROM link_table FORCE INDEX (id1_type)
WHERE link_type = 3 AND id1 = 1 AND visibility = 4 AND time >= 10
ORDER BY TIME DESC LIMIT 0;
id1 id2 link_type visibility data time version
SELECT variable_value INTO @bypass_executed_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_select_bypass_executed";
SELECT variable_value INTO @bypass_rows_read_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_rows_read";
SELECT rows_read INTO @bypass_rows_read_stat_new FROM
information_schema.table_statistics WHERE
table_name="link_table" and table_schema="test";
SELECT variable_value INTO @bypass_queries_point_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_point";
SELECT variable_value INTO @bypass_queries_range_new FROM
information_schema.global_status WHERE
variable_name="rocksdb_queries_range";
SELECT variable_value INTO @bypass_rows_sent_new FROM
information_schema.global_status WHERE
variable_name="rows_sent";
SELECT @bypass_executed_new - @bypass_executed_old;
@bypass_executed_new - @bypass_executed_old
5
SELECT @bypass_rows_read_new - @bypass_rows_read_old;
@bypass_rows_read_new - @bypass_rows_read_old
23
SELECT @bypass_rows_read_stat_new - @bypass_rows_read_stat_old;
@bypass_rows_read_stat_new - @bypass_rows_read_stat_old
23
SELECT @bypass_queries_point_new - @bypass_queries_point_old;
@bypass_queries_point_new - @bypass_queries_point_old
0
SELECT @bypass_queries_range_new - @bypass_queries_range_old;
@bypass_queries_range_new - @bypass_queries_range_old
5
SELECT @bypass_rows_sent_new - @bypass_rows_sent_old;
@bypass_rows_sent_new - @bypass_rows_sent_old
22
# Point query
SELECT /*+ bypass */ id1,id2,id1_type,id2_type,data,version FROM link_table
WHERE id1=1 AND id2=2 AND link_type=3;
Expand Down
Loading

0 comments on commit 6106eba

Please sign in to comment.