Hi,
This a follow on from thread
Have a query that takes >30secs.
The response table has 50K records, event 8K and action has 11K
can anyone see a way to improve this? please let me know if you need to see table structure
This a follow on from thread
Have a query that takes >30secs.
The response table has 50K records, event 8K and action has 11K
Code:
SELECT count(response.responseid) AS responsecount, event.userid
FROM event
INNER JOIN action ON action.eventid = event.eventid
INNER JOIN response ON response.actionid = action.actionid
INNER JOIN
(SELECT eventid FROM action
GROUP BY eventid
HAVING
COUNT(CASE WHEN typeid = '1' THEN 'count me' END) > 0
AND COUNT(CASE WHEN typeid = '2' THEN 'no, me!!' END) > 0 )
AS TA ON TA.eventid = event.eventid
WHERE action.typeid = '1'
AND date(action.actiondate) BETWEEN '20100801' AND '20100831'
GROUP BY event.eventid
ORDER BY event.eventid
can anyone see a way to improve this? please let me know if you need to see table structure