File: check_qep.inc

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 (52 lines) | stat: -rw-r--r-- 1,381 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
# include/check_qep.inc
#
# SUMMARY
#
#    Designed to be used together with include/check_qep.inc
#
#    $query should be assigned a select statement using 
#    straight_join to force the tables to be joined in most 
#    optimal order.
#
#    expect_qep.inc will then store the estimated 'Last_query_cost'
#    and total # 'Handler_read%' for this straight_joined query.
#
#    We should then assign a non-straight_join'ed version of
#    the same query to $query and execute it using 
#    'include/check_qep.inc'. Its estimated cost and
#    #handler_reads will then be verified against the
#    previous straight_joined query.
#
# USAGE
#
#    let $query= <select straight_join optimal statement>;
#    --source include/expect_qep.inc
#    let $query= <select statement>;
#    --source include/check_qep.inc
#
# EXAMPLE
#    t/greedy_optimizer.test
#

flush status;
eval EXPLAIN $query;
eval $query;

let $cost=
 query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);

--disable_warnings
let $reads=
`select sum(variable_value)
   from performance_schema.session_status
   where VARIABLE_NAME like 'Handler_read%'`;
--enable_warnings

#echo Cost: $cost, Handler_reads: $reads;

if ($cost != $best_cost)
{ echo ### FAILED: Query_cost: $cost, expected: $best_cost ###;
}
if ($reads != $best_reads)
{ echo ### FAILED: Handler_reads: $reads, expected: $best_reads ###;
}