mysql - Why I get "Copying to tmp table on disk" after several iteration of loop -
why "copying tmp table on disk" after several iteration of loop? in first few iterations have not this. table has 10 million , more rows. when set lover offset, loop execute more iteration without "tmp table".
my select is
select u.domena_id, u.umiestnenie, u.datum (select domena_id, min(datum) min_datum umiestnenie datum between 'date1' , 'date2' group domena_id limit 200000 offset offset (increasing in lopp) ) x inner join umiestnenie u on u.domena_id = x.domena_id , u.datum = x.min_datum
table umiestnenie
create table if not exists `umiestnenie` ( `id` int(11) not null auto_increment, `domena_id` int(11) not null, `datum` date not null, `umiestnenie` int(11) not null, primary key (`id`), key `fk_umiestnenie_domeny_idx` (`domena_id`), key `datum_idx` (`datum`) ) engine=innodb default charset=utf8 auto_increment=15243077 ;
table domena
create table if not exists `domena` ( `id` int(11) not null auto_increment, `nazov` varchar(200) not null, primary key (`id`), unique key `nazov` (`nazov`) ) engine=innodb default charset=utf8 auto_increment=15343156 ;
why when run select 1 time, doesn't need temporary table , when run select more times does?
this explain of select
1 primary <derived2> null null null null 1000000 1 primary u ref domena_id_idx domena_id_idx 4 x.domena_id 7 using 2 derived umiestnenie index null domena_id_idx 4 null 20109031 using
here not tmp table, when run select increased offset php see using of temp table.
Comments
Post a Comment