View Full Version : query takes too long to execute can anyone help?

08-16-2011, 12:24 AM
Hi All

this query

SELECT cdID, cdName, cdThumbIMG, cdThumbHeight, cdThumbWidth, cdRRP, cdBinding
FROM tbl_cds
WHERE cdBinding = '$cSect' && cdReleaseDate <= now()
ORDER BY cdReleaseDate DESC

takes approx 3.343secs to execute, thats not to bad i hear you say but this query is inside a loop and is ran 3 times on my page for 3 different cSects so thats 10 secs in total just for this query alone :(

now the table has 73000 rows in it and its the order by which is causing the slowness without that line it takes approx 0.0754secs to execute, big difference, if i can speed up this query at all, would lead to massive improvments on my pages load speed

many thanks

Old Pedant
08-16-2011, 12:39 AM
Add an index on the cdReleaseDate field.


08-16-2011, 12:45 AM
:) sweet thanks will give it a go

cheers mate