View Full Version : Query Optimisation

04-16-2013, 11:02 PM
Hi Everyone

I would be very grateful for a bit of assistance with optimising a query. The code is as follows:

CREATE TABLE table_name (

FROM table1 AS T1,
(SELECT column1, column2, COUNT(column1) AS cnt
FROM table1
GROUP BY column1
HAVING cnt>1
) AS T2

WHERE T1.column1 = T2.column1
AND T1.column2 = T2.column2
ORDER BY T1.column1

The query runs but times out even though column1 and column2 are both index columns.

Any suggestions would be most helpful.

Thanks in advance.

04-16-2013, 11:42 PM
Run an EXPLAIN on the query to find out whether the indexes are actually being used.