Page 1 of 1

Searching Indexed fileds.

Posted: Wed May 07, 2008 12:01 am
by G SHIVARANJANI
Hi,

I have a query regarding Indexes on coulmns of a table.


if there are 8 columns in a table say

col1,col2,col3,col4,col5,col6,col7,col8

and out of theses columns col1 , col2 , col3 together are indexed where all the three form a composite key.

Now if we try to search for col1 only or col2 only instead of all three together.

will the search take lesser time...or we need to put a index on col1 individually for the serch to be faster.

Thanks,

Posted: Wed May 07, 2008 4:16 am
by ray.wurlod
It would depend on the database server, on the type of index involved, and perhaps on the query optimizer. In general, however, if the two columns are the leading columns on a three-column index, then the index is likely to be used, if they are not the leading columns then the index is not likely to be used (unless the cost of not doing so is huge). Definitely "it depends".