Re: Clustered Indexes --- for primary keys or not John Salvo wrote:
>
> Performance and Tuning Guide
> Chapter 8 - Indexing for Performance --> Choosing Indexes --> Index keys
> and logical keys ( page 176 )
>
> "A common error is to create the clustered index for a table on the
> primary key, even though it is never used for range queries or ordering
> result sets."
Its not really clear but its telling you to put the clustered index
on the columns you would most frequently use for range queries or
ordered result sets. That's where the clustered index is most
effective. For a single keyed access or single row access, a non-
clustered index is OK. Note that this only really applies to APL
tables (since the concept of clustered isn't applicable to DOL
tables).
> However, when you create a primary key constraint on a table, the
> default is to create a clustered index:
>
> Reference Manual
> Chapter 2 - alter table ( page 270 )
>
> clustered | nonclustered
> "specifies that the index created by a unique or primary key constraint
> is a clustered or nonclustered index. clustered is the default (unless a
> clustered index already exists for the table) for primary key
> constraints; nonclustered is the default for unique constraints. There
> can be only one clustered index per table. See create index for more
> information."
>
> Arent't the 2 statements contradicting ?
Not really. The primary key would most likely be unique but it
needed be clustered.
-am © 2003 |