Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Indexng Tables

Re: Indexng Tables

From: Allen Kirby <akirby_at_att.com>
Date: 1997/06/02
Message-ID: <3392D4E7.62C7@att.com>#1/1

Shimsoft wrote:
>
> How do you build a composite index for a table. Namely, how do you determine the best order for the columns?

putting the most selective column (the one with the most distinct values) first may be slightly better for performance, but I doubt it would be very noticeable.

It will be noticeable if you are doing searches on a subset of the columns in the index. You can only use the index columns at the beginning of the index, so put the column(s) you use most at the beginning.
e.g.

create index itest on test (col1, col2, col3);

select * from test where col1 = 'x';
select * from test where col1= 'x' and col2 = 'y';

        Will both use the index whereas
select * from test where col2 = 'y';

        Will NOT (can't) use the index.

-- 
---
Allen Kirby			AT&T ITS Production Services
akirby_at_att.com			Alpharetta, GA.
Received on Mon Jun 02 1997 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US