set max_heap_table_size=2048000000;
set tmp_table_size=2048000000;

drop temporary table if exists ttmp_idx1;
create temporary table ttmp_idx1 (
 gid mediumint unsigned not null primary key auto_increment,
 ii tinyint unsigned not null default 0
) engine = memory;
drop temporary table if exists ttmp_idx2;
create temporary table ttmp_idx2 (
 gid mediumint unsigned not null primary key auto_increment,
 ii tinyint unsigned not null default 0
) engine = memory;

insert into ttmp_idx1(ii) values (0);
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;
insert into ttmp_idx2(ii) select ii from ttmp_idx1; insert into ttmp_idx1(ii) select ii from ttmp_idx2;

drop temporary table ttmp_idx2;
delete from ttmp_idx1 where gid mod 8 = 7;

update ttmp_idx1 set ii = ceil(rand() * 10);

drop temporary table if exists ttmp_mem_hash;
create temporary table ttmp_mem_hash (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using hash (ii)
) engine = memory;

drop temporary table if exists ttmp_mem_btree;
create temporary table ttmp_mem_btree (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using btree (ii)
) engine = memory;

drop temporary table if exists ttmp_myisam_btree;
create temporary table ttmp_myisam_btree (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using btree (ii)
) engine = myisam row_format = fixed;

drop temporary table if exists ttmp_myisam_hash;
create temporary table ttmp_myisam_hash (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using hash (ii)
) engine = memory row_format = fixed;

drop temporary table if exists ttmp_aria_btree;
create temporary table ttmp_aria_btree (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using btree (ii)
) engine = aria transactional = 0 row_format = fixed;

drop temporary table if exists ttmp_aria_hash;
create temporary table ttmp_aria_hash (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using hash (ii)
) engine = aria transactional = 0 row_format = fixed;

create table tmp_myisam_btree (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using btree (ii)
) engine = myisam row_format = fixed;

create table tmp_myisam_hash (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using hash (ii)
) engine = memory row_format = fixed;

create table tmp_aria_btree (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using btree (ii)
) engine = aria transactional = 0 row_format = fixed;

create table tmp_aria_hash (
 gid mediumint unsigned not null primary key,
 ii tinyint unsigned not null default 0,
 index using hash (ii)
) engine = aria transactional = 0 row_format = fixed;

insert into ttmp_mem_hash select * from ttmp_idx1;
insert into ttmp_mem_btree select * from ttmp_idx1;
insert into ttmp_myisam_hash select * from ttmp_idx1;
insert into ttmp_myisam_btree select * from ttmp_idx1;
insert into ttmp_aria_hash select * from ttmp_idx1;
insert into ttmp_aria_btree select * from ttmp_idx1;
insert into tmp_myisam_hash select * from ttmp_idx1;
insert into tmp_myisam_btree select * from ttmp_idx1;
insert into tmp_aria_hash select * from ttmp_idx1;
insert into tmp_aria_btree select * from ttmp_idx1;

update ttmp_mem_btree set ii = 2 where gid mod 5 = 0;
update ttmp_mem_hash set ii = 2 where gid mod 5 = 0;
update ttmp_myisam_hash set ii = 2 where gid mod 5 = 0;
update ttmp_myisam_btree set ii = 2 where gid mod 5 = 0;
update ttmp_aria_hash set ii = 2 where gid mod 5 = 0;
update ttmp_aria_btree set ii = 2 where gid mod 5 = 0;
update tmp_myisam_hash set ii = 2 where gid mod 5 = 0;
update tmp_myisam_btree set ii = 2 where gid mod 5 = 0;
update tmp_aria_hash set ii = 2 where gid mod 5 = 0;
update tmp_aria_btree set ii = 2 where gid mod 5 = 0;

drop temporary table if exists ttmp_mem_hash;
drop temporary table if exists ttmp_mem_btree;
drop temporary table if exists ttmp_aria_hash;
drop temporary table if exists ttmp_aria_btree;
drop temporary table if exists ttmp_myisam_hash;
drop temporary table if exists ttmp_myisam_btree;


