mysql query optimization with multiple groupings or order bye
This is what my current query looks like:
SELECT act.*, group_concat(act.owner_id order by act.created_at desc) as
owner_ids
FROM (select * from activities order by created_at desc) as act
INNER JOIN users on users.id = act.owner_id
WHERE (users.city_id = 1 and act.owner_type = 'User')
GROUP BY trackable_type, recipient_id, recipient_type
order by act.created_at desc
limit 20 offset 0;
Doing an explain
I have played around with this query a lot including indexes etc. Is there
any way to optimizes this query?
No comments:
Post a Comment