MySQL Forums
Forum List  »  Newbie

Re: Specifying multiple WHERE options within a group?
Posted by: Jay Pipes
Date: July 01, 2005 06:22AM

Callum,

I'm assuming that the TrackingActions table is simply two fields, Action and UserID (something like VARCHAR(30), INT). If so, it would be highly beneficial to this query to add a reverse Primary Key index in the form:

UNIQUE INDEX (UserID, Action)

as well as the PRIMARY KEY (Action, UserID)

Both these indexes will be used in the above query. The outermost TrackingActions SELECT would use the PRIMARY KEY index, while the self joins would use the UNIQUE INDEX on the reversed PRIMARY KEY.

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote




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.