MySQL Forums
Forum List  »  General

Re: Using an ENUM column in an index
Posted by: Tom Byars
Date: March 18, 2015 05:53AM

Note horseID,raceID is in itself a unique index (a horse can't be in the same race twice) but other indexes such as trainerID,raceID,Ord and ownerID,raceID,Ord need the Ord column as trainers/owners can have more than one runner in a race. The reason I added the Ord column to the horseID,raceID,Ord index was so that I would be able to group_concat a series of form figures without MySQL having to look beyond the index e.g.

select group_concat(
if(left(Ord,2)>'40',left(Ord,1),
if(left(Ord,2)<='09',mid(Ord,2,1),'0'))
separator '')
from Runner where horseID=hID and raceID<rID
order by raceID desc limit 10;

would return up to the last 10 form figures for horse hID prior to race rID
e.g. '16430PF721'
(hopefully) without having to even access the Runner table as all the information is present in the index.

Options: ReplyQuote


Subject
Written By
Posted
Re: Using an ENUM column in an index
March 18, 2015 05:53AM


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.