-
Notifications
You must be signed in to change notification settings - Fork 4k
/
Copy pathanalyze_histogram.test
79 lines (58 loc) · 2.08 KB
/
analyze_histogram.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# We need the Debug Sync Facility.
--source include/have_debug_sync.inc
--echo #
--echo # Bug#34288890 Histogram commands invalidate TABLE_SHARE
--echo #
--echo #
--echo # Verify that new queries do not wait for old queries to terminate.
--echo #
CREATE TABLE t1 (c1 INT) ENGINE=INNODB;
INSERT INTO t1 VALUES (1), (2);
ANALYZE TABLE t1;
--echo # Case 1/2: ANALYZE TABLE UPDATE HISTOGRAM
--enable_connect_log
--connect (con1,localhost,root)
SET DEBUG_SYNC="before_reset_query_plan SIGNAL first_select_ongoing WAIT_FOR second_select_finished";
--send SELECT c1 FROM t1
--connection default
SET DEBUG_SYNC="now WAIT_FOR first_select_ongoing";
ANALYZE TABLE t1 UPDATE HISTOGRAM ON c1;
# Without the patch, this SELECT would wait indefinitely.
SELECT c1 FROM t1;
SET DEBUG_SYNC="now SIGNAL second_select_finished";
--connection con1
--reap;
--echo # Case 2/2: ANALYZE TABLE DROP HISTOGRAM
--connection con1
SET DEBUG_SYNC="before_reset_query_plan SIGNAL first_select_ongoing WAIT_FOR second_select_finished";
--send SELECT c1 FROM t1
--connection default
SET DEBUG_SYNC="now WAIT_FOR first_select_ongoing";
ANALYZE TABLE t1 DROP HISTOGRAM ON c1;
# Without the patch, this SELECT would wait indefinitely.
SELECT c1 FROM t1;
SET DEBUG_SYNC="now SIGNAL second_select_finished";
--connection con1
--reap;
--echo #
--echo # Different TABLE objects can use different histograms.
--echo #
--connection con1
ANALYZE TABLE t1 UPDATE HISTOGRAM ON c1;
SET DEBUG_SYNC="after_table_open SIGNAL first_histogram_acquired WAIT_FOR second_histogram_acquired";
--send EXPLAIN SELECT c1 FROM t1 WHERE c1 < 3;
--connection default
SET DEBUG_SYNC="now WAIT_FOR first_histogram_acquired";
UPDATE t1 SET c1 = 3 WHERE c1 = 2;
ANALYZE TABLE t1 UPDATE HISTOGRAM ON c1;
--echo # Selectivity estimate (filtered) should be 50.00
SET DEBUG_SYNC="after_table_open SIGNAL second_histogram_acquired";
EXPLAIN SELECT c1 FROM t1 WHERE c1 < 3;
--connection con1
--echo # Selectivity estimate (filtered) should be 100.00
--reap;
--disconnect con1
--source include/wait_until_disconnected.inc
--connection default
--disable_connect_log
DROP TABLE t1;