SELECT COUNT(organization.ID)
FROM organization
WHERE organization.NAME IN (
SELECT organization.NAME
FROM organization
WHERE organization.NAME <> ''
AND organization.APPROVED = 0
AND organization.CREATED_AT > '2012-07-31 04:31:08'
GROUP BY organization.NAME
HAVING COUNT(organization.ID) > 1
)
This query finds duplicates, the problem is that it takes 6 seconds for the page to load because of the inner statement. Is there a way to make it run faster? MySQL database version 5.1.
Try to avoid
IN.