File: analyze_engine_stats2.test

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (74 lines) | stat: -rw-r--r-- 2,014 bytes parent folder | download | duplicates (2)
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
#
# r_engine_stats tests that require slow query log.
#
--source include/analyze-format.inc
--source include/have_sequence.inc
--source include/have_innodb.inc

--echo #
--echo # MDEV-34125: ANALYZE FORMAT=JSON: r_engine_stats.pages_read_time_ms has wrong scale
--echo #

# Each row is 1K.
create table t1 (
  a varchar(255),
  b varchar(255),
  c varchar(255),
  d varchar(255),
  primary key(a,b,c,d)
) engine=innodb character set latin1;

SET unique_checks=0, foreign_key_checks= 0;
begin;

# The data size is 160K * 1K = 160M 
#  16M / (page_size=16K) = 1K pages.
insert into t1 select
  repeat(uuid(), 7), 
  repeat(uuid(), 7), 
  repeat(uuid(), 7), 
  repeat(uuid(), 7)
from seq_1_to_16384;
commit;

SET GLOBAL innodb_fast_shutdown=0;
source include/restart_mysqld.inc;
set log_slow_verbosity='engine';
set long_query_time=0.0;

let $analyze_output= `analyze format=json
select * from t1 force index (PRIMARY) order by a desc, b desc, c desc, d desc`;
evalp set @js='$analyze_output';

set @pages_read_time_ms=
  (select json_value(@js,'$.query_block.nested_loop[0].table.r_engine_stats.pages_read_time_ms'));

let ANALYZE_PAGES=`select @pages_read_time_ms`;
let SLOW_LOG_FILE= `select @@slow_query_log_file`;

perl;
  my $slow_log_file= $ENV{'SLOW_LOG_FILE'} or die "SLOW_LOG_FILE not set";
  my $analyze_pages=$ENV{'ANALYZE_PAGES'};
  open(FILE, $slow_log_file) or die "Failed to open $slow_log_file";
  # We didn't run any queries touching a storage engine after the query of
  # interest, so we will be fine here if we just get the last occurrence of 
  # Pages_read_time: NNNN in the file
  while(<FILE>) {
    $slow_log_pages=$1 if (/Pages_read_time: ([0-9.]+)/);
  }
  close(FILE);
  
  if ( $slow_log_pages > $analyze_pages * 0.95 && 
       $slow_log_pages < $analyze_pages * 1.05) {
    print "\n\n  OK: pages_read_time is same in slow log and ANALYZE\n\n";
  } else {
    print "\n\n  FAIL: $slow_log_pages not equal to  $analyze_pages\n";
  }

EOF


set long_query_time=default;
drop table t1;