File: query_expression_big.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 (80 lines) | stat: -rw-r--r-- 2,910 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Subroutine script used by query_expression_big.test . It's raison d'ĂȘtre
# is to allow repeating the tests below for both INTERSECT and EXCEPT
# without redundancy.
#
# Input:  $query - a variable containing the SQL command to be analyzed
# Output: stdout only
#
--source include/elide_costs.inc

#
# Communicating with Perl subroutine in query_expression_record_elapsed.inc
# Input: SQL statements to run with EXPLAIN ANALYZE are communicated via a file:
#
--let COMMANDS = $MYSQLTEST_VARDIR/tmp/commands.sql
#
# Timings retrieved from the execution are to be found in this
# SQL table, put there by the Perl subroutine by parsing the result
# of the command, expected to be a EXPLAIN ANALYZE, possibly prepended with
# some SET variable commands.
CREATE TABLE timings(id INT AUTO_INCREMENT PRIMARY KEY, t FLOAT);

--echo # This will spill to disk with default TempTable size while
--echo # reading right table. 3rd fastest.
eval $query;
--replace_regex $elide_costs_and_rows
eval EXPLAIN FORMAT=tree $query;
exec echo "EXPLAIN ANALYZE $query" > $COMMANDS;
--source include/query_expression_record_elapsed.inc

--echo # Should not spill to disk. Fastest or 2nd fastest.
set internal_tmp_mem_storage_engine = MEMORY;
eval $query;
--replace_regex $elide_costs_and_rows
eval EXPLAIN FORMAT=tree $query;
exec echo "SET internal_tmp_mem_storage_engine = MEMORY;
           EXPLAIN ANALYZE $query" > $COMMANDS;
--source include/query_expression_record_elapsed.inc

#
--echo # This will spill to disk while reading left table. Slowest.
set internal_tmp_mem_storage_engine = default;
set max_heap_table_size=1024*2014;
set tmp_table_size = @@max_heap_table_size;

eval $query;
--replace_regex $elide_costs_and_rows
eval EXPLAIN FORMAT=tree $query;
exec echo "set max_heap_table_size=1024*2014;
           set tmp_table_size = @@max_heap_table_size;
           EXPLAIN ANALYZE $query" > $COMMANDS;
--source include/query_expression_record_elapsed.inc

--echo # Should not spill to disk. 2nd fastest or fastest.
set max_heap_table_size=1024*2014*1024;
set tmp_table_size = @@max_heap_table_size;

eval $query;
--replace_regex $elide_costs_and_rows
eval EXPLAIN FORMAT=tree $query;
exec echo "set max_heap_table_size=1024*2014*1024;
           set tmp_table_size = @@max_heap_table_size;
           EXPLAIN ANALYZE $query" > $COMMANDS;
--source include/query_expression_record_elapsed.inc

# Assert the expected ordering of timings
#
# Sometimes we see MEMORY (#2) winning, other times we see TempTable
# (#4) winning, so, merge those states by omitting them. We should
# see only the two slow scenarios: 1 and 3, in that order.
#
# Bug#34967296 Occasionally, 1 can be slower than 3, so don't assert
# on the order.
--sorted_result
SELECT id FROM timings ORDER BY t LIMIT 2 OFFSET 2;

# clean up
set tmp_table_size = default;
set internal_tmp_mem_storage_engine = default;
DROP TABLE timings;
--remove_file $COMMANDS