Debian Codegraph @

mysql-test/suite/ndbcluster/fetch_table_stats_count.test

raw
1 --source include/have_ndb.inc
2
3 --echo #
4 --echo # Showing the "ndb_fetch_table_stats" counter
5 --echo #
6 --echo # Since fetching table stats incurs one roundtrip to NDB it should not
7 --echo # be done more than strictly required, the "ndb_fetch_table_stats"
8 --echo # counter provides a means to check when table stats are fetched.
9
10 CREATE TABLE t1 (a int primary key) ENGINE = NDB;
11
12 let $count =
13 `SELECT VARIABLE_VALUE
14 FROM performance_schema.session_status
15 WHERE variable_name = 'NDB_FETCH_TABLE_STATS'`;
16
17 INSERT INTO t1 VALUES (1);
18 SELECT * FROM t1;
19
20 let $count =
21 `SELECT VARIABLE_VALUE-$count
22 FROM performance_schema.session_status
23 WHERE variable_name = 'NDB_FETCH_TABLE_STATS'`;
24 echo Table stats was fetched $count time (expected 1);
25
26 --echo # Another query using an open handler instance should not cause
27 --echo # table stats to be fetched again
28 SELECT * FROM t1;
29
30 let $count =
31 `SELECT VARIABLE_VALUE-$count
32 FROM performance_schema.session_status
33 WHERE variable_name = 'NDB_FETCH_TABLE_STATS'`;
34 echo Table stats was fetched $count times (expected 0);
35
36 --echo # Closing handler, should really not need to fetch
37 --echo # table stats again, but they seem to be
38 FLUSH TABLES t1;
39
40 let $count =
41 `SELECT VARIABLE_VALUE-$count
42 FROM performance_schema.session_status
43 WHERE variable_name = 'NDB_FETCH_TABLE_STATS'`;
44 echo Table stats was fetched $count times (oops! expected 0);
45
46 --echo # Running query again, should cause
47 --echo # table stats to be fetched once again
48 SELECT * FROM t1;
49
50 let $count =
51 `SELECT VARIABLE_VALUE-$count
52 FROM performance_schema.session_status
53 WHERE variable_name = 'NDB_FETCH_TABLE_STATS'`;
54 echo Table stats was fetched $count times (expected 1);
55
56 DROP TABLE t1;