MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
check_qep.inc
1 # include/check_qep.inc
2 #
3 # SUMMARY
4 #
5 # Designed to be used together with include/check_qep.inc
6 #
7 # $query should be assigned a select statement using
8 # straight_join to force the tables to be joined in most
9 # optimal order.
10 #
11 # expect_qep.inc will then store the estimated 'Last_query_cost'
12 # and total # 'Handler_read%' for this straight_joined query.
13 #
14 # We should then assign a non-straight_join'ed version of
15 # the same query to $query and execute it using
16 # 'include/check_qep.inc'. Its estimated cost and
17 # #handler_reads will then be verified against the
18 # previous straight_joined query.
19 #
20 # USAGE
21 #
22 # let $query= <select straight_join optimal statement>;
23 # --source include/expect_qep.inc
24 # let $query= <select statement>;
25 # --source include/check_qep.inc
26 #
27 # EXAMPLE
28 # t/greedy_optimizer.test
29 #
30 
31 flush status;
32 eval EXPLAIN $query;
33 eval $query;
34 
35 let $cost=
36  query_get_value(SHOW STATUS LIKE 'Last_query_cost', Value, 1);
37 
38 let $reads=
39 `select sum(variable_value)
40  from information_schema.session_status
41  where VARIABLE_NAME like 'Handler_read%'`;
42 
43 #echo Cost: $cost, Handler_reads: $reads;
44 
45 if ($cost != $best_cost)
46 { echo ### FAILED: Query_cost: $cost, expected: $best_cost ###;
47 }
48 if ($reads != $best_reads)
49 { echo ### FAILED: Handler_reads: $reads, expected: $best_reads ###;
50 }