views:

184

answers:

2

We have combined primary key with fields no, id and groupno

From Access, a WHERE condition such as WHERE no = '' & groupno = '' executes faster while the same thing slows down updates in SQL.

Once we have provided individual index of no & groupno, will it be faster?

Does it consider it as a combined key if we provide primary key with 3 three fields and no individual index based on those fields?

+3  A: 

In general it's going to prefer a single index (with you providing values for the left most fields) from the point of view of getting the filtering done quickly.

Also the more you touch indexed fields in an update, the more time is going to be spent doing index mainenance.

Be careful about reading too much into timings of doing sometthing once for small datasets - you could easily be looking at connection overhead instead.

I suggest having a look in the quey plan via Query Analyzer/SQL Server Management Studio - this will allow you to see which index its actually really using, so you're not probing in the dark.

Ruben Bartelink
A: 

What version of SQL? An index will not speed up querying NULL values as these are not placed in indexes, for Oracle any way.

Martlark