Debian Codegraph @

mysql-test/suite/ndb_opt/index_stat_kernel.test

raw
1 --source include/have_ndb.inc
2
3 #
4 # Basic test to verify the automatic creatiion and update of
5 # index stats in the kernel
6 #
7
8 CREATE TABLE table_with_one_index (
9 a INT NOT NULL,
10 b INT NOT NULL,
11 PRIMARY KEY USING HASH (a),
12 INDEX (b)
13 ) ENGINE NDB;
14
15 --echo Check if the stats have been automatically created
16 --let $index_stat_db=test
17 --let $index_stat_table=table_with_one_index
18 --source check_index_stat_created.inc
19
20 --echo Insert rows to trigger automatic update of stats
21 --disable_query_log
22 --let $i = 1000
23 while ($i)
24 {
25 --dec $i
26 --eval INSERT INTO table_with_one_index VALUES ($i, $i % 10)
27 }
28 --enable_query_log
29
30 --echo Wait for stats update
31 --let $index_stat_db=test
32 --let $index_stat_table=table_with_one_index
33 --source wait_index_stat_updated.inc
34
35 --echo Insert more rows to trigger another automatic update of stats
36 --disable_query_log
37 # The fragment being tracked for index stats has around 125 (1000/8) rows at this
38 # point. Inserting 250 more rows in the table should lead to around 30 new rows
39 # in the fragment.
40 #
41 # Change % in fragment = 30/155*100 = 19.35%
42 # Scale factor = 1 + 100% * log2 (155) = 8.25 (approximately)
43 # Scaled trigger % = 100/8.25 = 12.12%
44 # Thus, the inserting 250 rows should lead to a stats update.
45 #
46 # Inserting 150 rows instead of 250 did not trigger a stats update
47 # in manual testing.
48 --let $i = 1250
49 while ($i > 1000)
50 {
51 --dec $i
52 --eval INSERT INTO table_with_one_index VALUES ($i, $i % 10)
53 }
54 --enable_query_log
55
56 --echo Wait for stats update
57 --let $index_stat_db=test
58 --let $index_stat_table=table_with_one_index
59 --let $expected_version=2
60 --source wait_index_stat_updated.inc
61
62 DROP TABLE table_with_one_index;