4 ms·
OP - Can you please run your original query with a minor variation- select dashboards.name, count(distinct time_on_site_logs.user_id) from time_on_site_l
by corresation 13y ago
OP - Can you please run your original query with a minor variation-
select
dashboards.name,
count(distinct time_on_site_logs.user_id)
from time_on_site_logs
join dashboards on time_on_site_logs.dashboard_id = dashboards.id
group by time_on_site_logs.dashboard_id, dashboards.name
order by count desc
- hglaser 13y agoGood idea. Times are from my laptop, which is less beefy than the test rig we used: First query: 996s First query with your variation: 593s Second query: 67s Third query: 21s
- corresation 13y agoDo you have a FK from dashboard_id to dashboards.id by chance? I assume no, as the query is presumably still forced to do an early existence test of the inner join before aggregating.