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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
|
--source include/have_debug.inc
--source include/not_hypergraph.inc # Does not use internal temporary tables yet.
#============
# Temporary table fallback on lack of memory test
#============
# ---------------------------------------------------------------------
# Prepare
#
--echo # Disable sorting by addon fields, as that will enable the
--echo # StreamingIterator in many of the test cases, resulting in
--echo # fewer materializations.
SET debug = '+d,filesort_force_sort_row_ids';
CREATE TABLE t (c VARCHAR(128));
INSERT INTO t VALUES
(REPEAT('a', 128)),
(REPEAT('b', 128)),
(REPEAT('c', 128)),
(REPEAT('d', 128));
ANALYZE TABLE t;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
--echo # ---------------------------------------------------------------------
--echo # Scenario 1: (ENGINE=MEMORY, LIMIT=default, CASE=basic, RESULT=success)
--echo #
SET @@internal_tmp_mem_storage_engine = MEMORY;
--disable_result_log
SELECT * FROM
t AS t1,
t AS t2,
t AS t3,
t AS t4,
t AS t5,
t AS t6
ORDER BY 1
LIMIT 2;
--enable_result_log
SELECT @@internal_tmp_mem_storage_engine;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
SET @@internal_tmp_mem_storage_engine = default;
--echo # ---------------------------------------------------------------------
--echo # Scenario 2: (ENGINE=MEMORY, LIMIT=default, CASE=no-std-memory, RESULT=ondisk_fallback)
--echo #
SET @@internal_tmp_mem_storage_engine = MEMORY;
SET @@max_heap_table_size = 16384;
--disable_result_log
SELECT * FROM
t AS t1,
t AS t2,
t AS t3,
t AS t4,
t AS t5,
t AS t6
ORDER BY 1
LIMIT 2;
--enable_result_log
SELECT @@internal_tmp_mem_storage_engine;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
SET @@internal_tmp_mem_storage_engine = default;
SET @@max_heap_table_size = default;
--echo # ---------------------------------------------------------------------
--echo # Scenario 3: (ENGINE=TempTable, LIMIT=default, CASE=basic, RESULT=success)
--echo #
SET @@internal_tmp_mem_storage_engine = TempTable;
--disable_result_log
SELECT count_alloc
FROM performance_schema.memory_summary_global_by_event_name
WHERE event_name = 'memory/temptable/physical_disk'
INTO @id1;
SELECT * FROM
t AS t1,
t AS t2,
t AS t3,
t AS t4,
t AS t5,
t AS t6
ORDER BY 1
LIMIT 2;
SELECT count_alloc
FROM performance_schema.memory_summary_global_by_event_name
WHERE event_name = 'memory/temptable/physical_disk'
INTO @id2;
--enable_result_log
SELECT @@internal_tmp_mem_storage_engine;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
SELECT (@id1=@id2);
--echo # ---------------------------------------------------------------------
--echo # Scenario 4: (ENGINE=TempTable, LIMIT=default, CASE=no-std-memory, RESULT=use_tempfiles)
--echo #
SET @@internal_tmp_mem_storage_engine = TempTable;
SET GLOBAL temptable_max_ram = 2097152;
--disable_result_log
SELECT count_alloc
FROM performance_schema.memory_summary_global_by_event_name
WHERE event_name = 'memory/temptable/physical_disk'
INTO @id1;
SELECT * FROM
t AS t1,
t AS t2,
t AS t3,
t AS t4,
t AS t5,
t AS t6
ORDER BY 1
LIMIT 2;
SELECT count_alloc
FROM performance_schema.memory_summary_global_by_event_name
WHERE event_name = 'memory/temptable/physical_disk'
INTO @id2;
--enable_result_log
SELECT @@internal_tmp_mem_storage_engine;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
SELECT (@id1<@id2);
SET @@internal_tmp_mem_storage_engine = default;
SET GLOBAL temptable_max_ram = default;
--echo # ---------------------------------------------------------------------
--echo # Scenario 5: (ENGINE=TempTable, LIMIT=default, CASE=no-disk-memory, RESULT=error)
--echo #
SET @@internal_tmp_mem_storage_engine = TempTable;
SET GLOBAL temptable_max_ram = 2097152;
SET debug = '+d,temptable_fetch_from_disk_return_null';
# When both RAM and MMAP limit is exhausted, optimizer shall recover by spilling over to new tmp disk tables (InnoDB)
-- disable_result_log
SELECT * FROM
t AS t1,
t AS t2,
t AS t3,
t AS t4,
t AS t5,
t AS t6
ORDER BY 1
LIMIT 2;
-- enable_result_log
SELECT @@internal_tmp_mem_storage_engine;
SHOW STATUS LIKE 'Created_tmp_tables';
SHOW STATUS LIKE 'Created_tmp_disk_tables';
SET @@internal_tmp_mem_storage_engine = default;
SET GLOBAL temptable_max_ram = default;
SET debug = '-d,temptable_fetch_from_disk_return_null';
# ---------------------------------------------------------------------
# Cleanup
#
DROP TABLE t;
SET optimizer_switch="hash_join=on";
|