Re: Indexing Question.
From: Keith Thompson <mcdoo_at_worldgate.edmonton.ab.ca>
Date: 9 Feb 1995 02:42:52 GMT
Message-ID: <3hbvfc$j0k_at_scanner.worldgate.edmonton.ab.ca>
Date: 9 Feb 1995 02:42:52 GMT
Message-ID: <3hbvfc$j0k_at_scanner.worldgate.edmonton.ab.ca>
In article <3h0uec$lb_at_charnel.ecst.CSUChico.EDU>, tvangod_at_ecst.csuchico.edu (Tyler Van Gorder) says:
>If you have a 4 part primary key do you need to define an index on each
>column or can you define an index on the entire key. If the second is
>the case, how is performance when say 2 of the 4 columns are supplied in
>a query?
Yes, you can build an index on the entire key. When you supply only part of the key in a query, the index will be used if and only if the values you supply are a leading portion of the key. That is, given an index on columns A, B, C, and D for table Q:
These queries will use the index
SELECT column_list FROM Q WHERE A = 'hi'; SELECT column_list FROM Q WHERE A = 'hi' AND B = 'there' AND C = 'Tyler';
While this query will not:
SELECT column_list FROM Q WHERE A = 'hi' AND C = 'Tyler'
Hope this helps.
Keith Thompson *<:o) Received on Thu Feb 09 1995 - 03:42:52 CET