I am trying to get a count of the polls that need to be taken, which are stored in seotc, and the number of completed polls is stored seotcresults_v2. The table seotccontains almost 100 thousand records, and the table seotcresults_v2takes about half of this. How can I speed up this request?
SELECT
DISTINCT seotcresults_v2.Clock,
COUNT(seotc.Id) AS Surveys,
COUNT(seotcresults_v2.Id) AS Complete
FROM seotc
JOIN seotcresults_v2 ON seotcresults_v2.Clock = seotc.Clock
WHERE seotcresults_v2.CampusID = 40
AND seotcresults_v2.Term = 201011
ORDER BY seotc.Clock
UPDATE:
Thanks for all the answers. The table structure (minimum) is as follows:
seotc: | Id | Watch | CampusID | Term |
seotcresults_v2: | Id | Watch | CampusID | Term | Q1 | Q2 | ... etc.
Id - this is an index with automatic increment in each table for surveys and survey results
'Clock' - seotc seotcresults_v2, , . , , , . ?
EXPLAIN, .