Understand EXPLAIN mysql -
i trying interpret explain of mysql on query,this table:
create table text_mess( datamess timestamp(3) default 0, sender bigint , recipient bigint , roger boolean, msg char(255), foreign key(recipient) references users (tel) on delete cascade on update cascade, primary key(datamess,sender) ) engine = innodb
this first type of query :
explain select /*!straight_join*/datamess, sender,recipient,roger,msg text_mess join (select max(datamess)as dmess text_mess roger = true group sender,recipient) max on text_mess.datamess=max.dmess ;
and second:explain
explain select /*!straight_join*/datamess, sender,recipient,roger,msg (select max(datamess)as dmess text_mess roger = true group sender,recipient) max join text_mess on max.dmess = text_mess.datamess ;
the 2 queries asking same thing, difference order of ref_table (driving_table), in first case text_mess, in second case sub query : ![first , second query][1]
as can see difference in order of first 2 lines, question in particular on second (the faster query ) second line should inner-table, if so, why column ref tells me: max.dmess, should column of ref-table (sub-query). and, last row referred on how first built? , in end think there more efficient query?
Comments
Post a Comment