I have a query that currently takes around 5 minutes to return results.
I have run it through the Index Tuning wizard (on Thorough) and it had no recommendations.
I will layout the query, the field types, and the current indexes. If you have any thoughts, please let me know.
Here is the query:
On tbl_advertisement:
- The primary key is a field called ad_id (int), not used in this query
- the field content_id (int) is a UNIQUE index
On tbl_server_logs:
- The primiary key consists of 4 fields: server_install_id (int), zone_id(int), play_time(datetime), and log_type_id (int)
- There are 3 other indexes on this table which have been implemented for other queries:
1.) play_time, server_install_id, log_type_id, content_id
2.) server_install_id, play_time, log_type_id, content_id
3.) content_id, server_install_id, play_time, log_type_id
All fields in the above 3 indexes are "Ascending" and none are UNIQUE
Concerning table data, tbl_advertisement currently contains 4,518 rows and tbl_server_logs currently contains 227,158,649 rows
Any suggestions on what might improve this query execution time would be greatly appreciated.
If there is any details that I left out that might be helpful, let me know.
Thanks,
Blake
I have run it through the Index Tuning wizard (on Thorough) and it had no recommendations.
I will layout the query, the field types, and the current indexes. If you have any thoughts, please let me know.
Here is the query:
Code:
SELECT tbl_server_logs.server_id, Count(tbl_server_logs.content_id) AS Total
FROM tbl_server_logs, tbl_advertisement
WHERE tbl_advertisement.content_id = tbl_server_logs.content_id
AND tbl_server_logs.zone_id = 1
AND tbl_server_logs.play_time > '2/1/2005'
And tbl_server_logs.play_time < '3/1/2005'
AND tbl_server_logs.log_type_id = 9
GROUP BY server_install_id
On tbl_advertisement:
- The primary key is a field called ad_id (int), not used in this query
- the field content_id (int) is a UNIQUE index
On tbl_server_logs:
- The primiary key consists of 4 fields: server_install_id (int), zone_id(int), play_time(datetime), and log_type_id (int)
- There are 3 other indexes on this table which have been implemented for other queries:
1.) play_time, server_install_id, log_type_id, content_id
2.) server_install_id, play_time, log_type_id, content_id
3.) content_id, server_install_id, play_time, log_type_id
All fields in the above 3 indexes are "Ascending" and none are UNIQUE
Concerning table data, tbl_advertisement currently contains 4,518 rows and tbl_server_logs currently contains 227,158,649 rows
Any suggestions on what might improve this query execution time would be greatly appreciated.
If there is any details that I left out that might be helpful, let me know.
Thanks,
Blake