MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimize sub query with large group by
Posted by: Alex K
Date: March 14, 2011 07:15PM

I don't use object_id anywhere else because I don't care which object it was. I just want to make sure that only the latest person to access each object gets credit.

The innermost query sorts all the of the events by date (most recent first). The query outside that uses the group by trick to select only the first event for each object. The outermost query then counts up how many per person.

I am not sure how this would benefit from compound indexes as each query is only grouped/ordered by one column and there are no where clauses.

Should I just expect that this sort of query is bound to take several minutes when there are around 10 million events.

Options: ReplyQuote

Written By
March 10, 2011 07:44PM
Re: Optimize sub query with large group by
March 14, 2011 07:15PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.