File: index_stat_kernel.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (62 lines) | stat: -rw-r--r-- 1,660 bytes parent folder | download
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
--source include/have_ndb.inc

#
# Basic test to verify the automatic creatiion and update of
# index stats in the kernel
#

CREATE TABLE table_with_one_index (
  a INT NOT NULL,
  b INT NOT NULL,
  PRIMARY KEY USING HASH (a),
  INDEX (b)
) ENGINE NDB;

--echo Check if the stats have been automatically created
--let $index_stat_db=test
--let $index_stat_table=table_with_one_index
--source check_index_stat_created.inc

--echo Insert rows to trigger automatic update of stats
--disable_query_log
--let $i = 1000
while ($i)
{
  --dec $i
  --eval INSERT INTO table_with_one_index VALUES ($i, $i % 10)
}
--enable_query_log

--echo Wait for stats update
--let $index_stat_db=test
--let $index_stat_table=table_with_one_index
--source wait_index_stat_updated.inc

--echo Insert more rows to trigger another automatic update of stats
--disable_query_log
# The fragment being tracked for index stats has around 125 (1000/8) rows at this
# point. Inserting 250 more rows in the table should lead to around 30 new rows
# in the fragment.
#
# Change % in fragment = 30/155*100 = 19.35%
# Scale factor = 1 + 100% * log2 (155) = 8.25 (approximately)
# Scaled trigger % = 100/8.25 = 12.12%
# Thus, the inserting 250 rows should lead to a stats update.
#
# Inserting 150 rows instead of 250 did not trigger a stats update
# in manual testing.
--let $i = 1250
while ($i > 1000)
{
  --dec $i
  --eval INSERT INTO table_with_one_index VALUES ($i, $i % 10)
}
--enable_query_log

--echo Wait for stats update
--let $index_stat_db=test
--let $index_stat_table=table_with_one_index
--let $expected_version=2
--source wait_index_stat_updated.inc

DROP TABLE table_with_one_index;