MySQL Forums
Forum List  »  Performance

Re: Help optimizing a SELECT WHERE GROUP BY query
Posted by: Jay Pipes
Date: September 05, 2005 11:42AM

Rob, to get better performance from your query, consider splitting the main IN clause out into multiple UNIONed SELECTs. This will perform better than a single one in some cases. Example:

SELECT word_id,tax_id, COUNT(*), num_genes
FROM gene2word
WHERE locuslink_id in ( ... 500 values ... )
GROUP BY word_id, tax_id
UNION ALL
SELECT word_id,tax_id, COUNT(*), num_genes
FROM gene2word
WHERE locuslink_id in ( ... next 500 values ... )
GROUP BY word_id, tax_id
UNION ALL
SELECT word_id,tax_id, COUNT(*), num_genes
FROM gene2word
WHERE locuslink_id in ( ... next 500 values ... )
GROUP BY word_id, tax_id;

This is a variation on the pre 5.0 index merge tricks...

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Help optimizing a SELECT WHERE GROUP BY query
1691
September 05, 2005 11:42AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.