· 9 years ago · Dec 07, 2016, 10:23 PM
1DROP DATABASE IF EXISTS test;
2CREATE DATABASE IF NOT EXISTS test;
3USE test;
4
5CREATE TABLE main(
6 id INTEGER UNIQUE NOT NULL AUTO_INCREMENT PRIMARY KEY,
7 value INTEGER
8);
9
10delimiter #
11create procedure load_data(IN _max INTEGER)
12begin
13
14declare counter int unsigned default 0;
15
16 truncate table main;
17 start transaction;
18 while counter < _max do
19 set counter=counter+1;
20 insert into main (value) values (counter);
21 end while;
22 commit;
23end #
24
25delimiter ;
26
27call load_data(25000);
28
29-- SET max_heap_table_size = 16*1024*1024;
30
31CREATE TABLE memory_main (
32 id INTEGER UNIQUE NOT NULL AUTO_INCREMENT PRIMARY KEY,
33 value INTEGER
34) ENGINE=MEMORY
35AS SELECT * FROM main;
36
37SELECT
38 table_name AS `Table`,
39 round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
40FROM information_schema.TABLES
41WHERE table_schema = "test"
42 AND table_name LIKE "%main%";