set max_heap_table_size=2048000000;
set tmp_table_size=2048000000;

create temporary table ttmp_idx1 (
 gid mediumint unsigned not null primary key auto_increment,
 ii mediumint unsigned not null default 0
) engine = memory;
create temporary table ttmp_idx2 (
 gid mediumint unsigned not null primary key auto_increment,
 ii mediumint 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() * 1000);

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

insert into ttmp_mem_hash select * from ttmp_idx1;

update ttmp_mem_hash set ii = gid where gid mod 5 = 0;
update ttmp_mem_hash set ii = 2 where gid mod 5 = 0;
update ttmp_mem_hash set ii = gid where gid mod 5 = 0;
update ttmp_mem_hash set ii = 2 where gid mod 5 = 0;

delete from ttmp_mem_hash where gid mod 5 = 1;
delete from ttmp_mem_hash where gid mod 5 = 0;

drop temporary table if exists ttmp_mem_hash;


