Re: Help with composite indices
Posted in 1997
The ordering of columns in the index is critical. Assume you have an index on columns A, B and C - listed in that order in the CREATE INDEX statement. As I understand it you can, in either, SELECT or ORDER BY, usefully refer to A alone, A and B or A, B and C. You can't usefully refer to B or C alone or B and C. If you refer to A and C only, then the index will only be used for A. In other words, if there's a gap in your references to the columns then the columns after the gap won't get used. That right, johnl? Ian Bradford Young wrote: > > I've read how to create a composite index, but I'm unsure about > how to use one to order output or join tables. In my db, I have > tables with company id's and dates, with the combination of > id and date being unique. So I can create an index on (id, date). > Can I use that index for joining tables? > Can I use that index when I come to the "order by" part of a > select statement? > > Many thanks. > -- > -------------------------------------------------------------------- > Bradford Young E-mail: byoung@cornercap.com > Cornerstone Capital Corp. Tel: (404) 870-0700 > Atlanta, GA Fax: (404) 870-0770