In a 5,500 rows tableset - the following query took 202.30 sec in MySQL Control Center prior to a "analyze table partners; analyze table phones;" query!!
select s.id as id, s.label_text, p.phone_number as phonenumber, f.phone_number as faxnumber from partners as s
left join phones as p on s.aid=p.aid and p.phone_type=0 and p.preferred=1
left join phones as f on s.aid=f.aid and f.phone_type=1 and f.preferred=1
where s.partner_type<3 and s.voided_by=0
So - my 'tip' is to really RTFM very carefully where it says: run analyze table frequently
(needless to say that after the analyze query - mySQL provided me with the initial 1,000 rows in just under 500 msecs!!)
select s.id as id, s.label_text, p.phone_number as phonenumber, f.phone_number as faxnumber from partners as s
left join phones as p on s.aid=p.aid and p.phone_type=0 and p.preferred=1
left join phones as f on s.aid=f.aid and f.phone_type=1 and f.preferred=1
where s.partner_type<3 and s.voided_by=0
So - my 'tip' is to really RTFM very carefully where it says: run analyze table frequently
(needless to say that after the analyze query - mySQL provided me with the initial 1,000 rows in just under 500 msecs!!)
kannste auch mal laufen lassen
Kommentar