[dba-SQLServer] Clustered Index first or last

jwcolby jwcolby at colbyconsulting.com
Fri Sep 24 11:01:08 CDT 2010


For anybody interested, building the clustered index before appending records (instead of building 
the index after appending records) into the table decreased the time to append by roughly 30%.  This 
is in the case where I have a PK (autoincrement) as the key for the index and am inserting records 
in order sorted by the PK.

John W. Colby
www.ColbyConsulting.com

On 9/23/2010 2:58 PM, jwcolby wrote:
> When I build my 65 million record table, I almost always create a clustered index, with the key
> being the PK which is an autonumber integer.
>
> In the past I always inserted the records, then built the index.  However if the records are
> inserted in sorted order on the PKID, which is in ascending order, is there any reason not to create
> the clustered index and then insert the records.  Since the key is ascending each new record should
> go at the end, no shuffling around to put things in the middle.
>
> It seems I would actually *save* time doing it that way.
>
> Yes, or no?



More information about the dba-SQLServer mailing list