views:

434

answers:

2

To be more specific (since the general answer to the subject is likely "yes"):

We have a table with lots of data in Sybase.

One of the columns is "date of insertion" (DATE, datetime type).

The clustered index on the table starts with the "DATE".

Question: For another, non-clustered index, does the order of columns (more specifically, whether "DATE" is the first or a second index column) affect the insert query performance?

Assume everything else is equal, e.g. the order of the second non-clustered index does not affect select query performance (even if it does, I don't care for the purposes of this question).

A: 

I believe it is largely determined by the Fill factor in the indexes and to a much lesser extent how selective the columns are.

Mitch Wheat
How can one determine fill factor of an existing index on Sybase? The index creation statement didn't contain any explicit fill factor.
DVK
Query against sysobjects and sysindexes:select o.name, i.name,i.fill_factor, i.exp_rowsize from sysobjects o JOIN sysindexes i ON (o.id = i.id)Also, look at the output of sp_configure 'default fill factor'
Paul Harrington
+2  A: 

what locking scheme is in place on the table All-pages or data-pages? (you can find out by selecting lockscheme('table_name'). The (application-observed) performance of index-maintenance is much better with data-pages locking scheme.

An index is ordered. The insert time depends on the cost of maintaining that order. If you insert rows with monotonically increasing values for the columns which are indexed then the index will grow 'at the end' and performance will be great (modulo any concurrency issues due to multiple concurrent updaters). The index tree will have to be re-balanced from time to time but I believe that is a rapid operation.

If the order of inserts is not in the same order as an index then that index will have to have entries inserted 'into the middle' and this is likely to cause page-splits (modulo there being sufficient space left unallocated by setting a fill-factor as mentioned above) and also 'index fragmentation'

anyway, the answer -- as always -- is to conduct some experiments and measure elapsed time and IO activity. You also might want to look at the optdiag output.

pjjH

Paul Harrington