MySQL Forums
Forum List  »  InnoDB

Re: Slow Query, Two Large tables, Simple FKey Join
Posted by: KimSeong Loh
Date: December 02, 2007 07:52AM

Do you mean sa.session_id is a foreign key referencing s.id? And s.id is a primary key?

Then you only need.
Select count(sa.id) from sessionaction sa where
sa.action_id=<some number>

Reason, every sa.action_id has an equivalent s.id and exactly 1 row in table s, so the join s.id=sa.action.id is redundant if all you need is to count(sa.id).

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Slow Query, Two Large tables, Simple FKey Join
2786
December 02, 2007 07:52AM


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.