Thanks baron for you reply. Here is the result from the explain:

1 SIMPLE t2 ref PRIMARY,url url 194 const 1 Using where; Using temporary;
Using filesort
1 SIMPLE tm1 index PRIMARY PRIMARY 8 NULL 149115 Using index
1 SIMPLE t1 eq_ref PRIMARY,url PRIMARY 4 rubbetdev.tm1.tag_id 1 Using where
1 SIMPLE tm2 eq_ref PRIMARY PRIMARY 8
rubbetdev.t2.id,rubbetdev.tm1.ad_id 1 Using
where; Using index

2008/3/5, Baron Schwartz <[EMAIL PROTECTED]>:
>
> Hi,
>
>
> On Wed, Mar 5, 2008 at 9:11 AM, Johan Thorvaldsson <[EMAIL PROTECTED]>
> wrote:
> > I need help to optimize this following query. It runs very slow and I
> cant
> >  find any direct errors in it.
> >  SELECT
> >  1 * t1.termfreq as viktatantal,
> >  t1.tag, t1.url FROM tag_keys t1
> >  LEFT JOIN tag_ad_map tm1 ON t1.id = tm1.tag_id
> >  LEFT JOIN tag_ad_map tm2 ON tm1.ad_id = tm2.ad_id
> >  LEFT JOIN tag_keys t2 ON t2.id = tm2.tag_id
> >   WHERE
> >   t2.url = 'motor' AND t1.url != 'motor'
> >  GROUP BY t1.id
> >  ORDER BY viktatantal DESC, RAND()
> >  LIMIT 80
> >
> >  Any help would be very appriciated!
>
>
> You should use EXPLAIN.  If you don't understand the output of
> EXPLAIN, post the output back to this list and we can help you
> understand it.
>
> Cheers
>
> Baron
>

Reply via email to