Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Primary key question Expand / Collapse
Posted Wednesday, January 23, 2013 2:28 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, July 14, 2016 2:09 PM
Points: 317, Visits: 1,344
I'm planning to move data from one database to another on the same server. I've DDL scripts ready to create objects on the new database but I'm not sure if I've to create primary keys before loading the data since I think it will slow up the load. So my question is, do I need to create the primary keys before loading or after loading the data?
Post #1410797
Posted Thursday, January 24, 2013 2:34 AM



Group: General Forum Members
Last Login: Thursday, September 1, 2016 2:56 AM
Points: 5,969, Visits: 6,067
That is one for testing per your environment as either could produce the best result.

I would do a test without the primary key, insert the data, create the primary key and time it.

Then truncate the table and import the data again.

That way you have a time it takes to import and create the key VS time it takes to import with the key existing, then you can make an informed choice.

Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1411002
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse