List:General Discussion« Previous MessageNext Message »
From:Dan Nelson Date:April 11 2000 7:26pm
Subject:Re: are indexes used on a self join?
View as plain text  
In the last episode (Apr 11), Mark Maggelet said:
> Hello, can somebody give me some feedback on a query like this:
> select distinct(products.id) from products,keywords as a,keywords as b
>    where (products.id=a.id and a.keyword ='black') and (b.keyword ='history');
> 
> This query is taking 24 seconds, which is way too long. products.id has an index,
> and keywords.keyword also has an index, but I'm not sure that the index for
> keywords.keyword is being used since I alias it twice.

what does an EXPLAIN on the query look like?

-- 
	Dan Nelson
	dnelson@stripped
Thread
are indexes used on a self join?Mark Maggelet11 Apr
  • Re: are indexes used on a self join?Dan Nelson11 Apr
    • Re: are indexes used on a self join?Mark Maggelet11 Apr
  • Re: are indexes used on a self join?Gerald Clark12 Apr
    • Re: are indexes used on a self join?Mark Maggelet12 Apr
      • Re: are indexes used on a self join?Dan Nelson12 Apr