Which query will be faster?

Post Reply
Faiz
Posts: 109
Joined: Wed Jan 10, 2001 1:29 pm

Which query will be faster?

Post by Faiz »

Hi,
Which one of the following query will be faster in terms of performance,
1) select * from html
where Title\Description\Keywords\Body likep $query
and (ProductId in ($prod))

Then display the results.
If there are 100 rows in the table, then $prod will not be less than 90. (meaning, it will almost be a full table scan with an extra overhead in the query)

OR

2) select * from html
where Title\Description\Keywords\Body likep $query

Then display the results after filtering out only those results which belong to $prod.
My guess is, the 2nd query will be better (without any overhead). I hope I am able to explain what I mean.
Regards,
Faiz
Posts: 109
Joined: Wed Jan 10, 2001 1:29 pm

Which query will be faster?

Post by Faiz »

Thanx. Will the first query be still better if I have a sub-query in place of $prod, for example,
select * from html
where Title\Description\Keywords\Body likep $query
and (ProductId in (select ProductId from products
where RestrictedFlag=0))

Right now, I have a metamorph inverted index on (Title\Description\Keywords\Body,ProductId). How different is compound index from inverted index? How can I create a compound index? In case of a compound index, do I have to use LIKE instead of LIKEP? Will it affect the search results in terms of relevant documents?
p.s. thanx for the prompt reply.
Post Reply