Em 11/9/2011 15:11, firebirdsql escreveu:
> If I a tables primary key is (username, title, start_date)...I'm guessing it 
> will create an index on (username, title, start_date).
>
> If I'm querying by username, start_date, will it still use the index OR do I 
> need to add an extra index for username, start_date)?
>
>
>

It depends if the segment USERNAME is selective enough, probably it 
will, but it won't use the START_DATE portion of the index.

I prefer to use Surrogste Keys to be used as PK's, and create aditional 
index on single fields for the most used fields that I use to filter out 
records.

Give it a try and you will see if the index is used or not.

Then try to create another index just on START_DATE and try the query 
again, I think it will use both indices, after that try to create an 
index on USERNAME and try again the query.

Execute the query a couple of times using it index combination and see 
if you get a better performance or not.

see you !

Reply via email to