Improve long mysql query
Posted
by John Adawan
on Stack Overflow
See other posts from Stack Overflow
or by John Adawan
Published on 2010-04-16T05:21:14Z
Indexed on
2010/04/16
5:23 UTC
Read the original article
Hit count: 240
mysql-query
I have a php mysql query like this
$query = "SELECT * FROM articles FORCE INDEX (articleindex) WHERE category='$thiscat' and did>'$thisdid' and mid!='$thismid' and status='1' and group='$thisgroup' and pid>'$thispid' LIMIT 10";
As optimization, I've indexed all the parameters in articleindex and I use force index to force mysql to use the index, supposedly for faster processing.
But it seems that this query is still quite slow and it's causing a jam and maxing out the max mysql connection limit.
Let's discuss how we can improve on such long query.
© Stack Overflow or respective owner