Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Using GUIDs as primary keys/clustered indexes Expand / Collapse
Author
Message
Posted Tuesday, September 4, 2012 5:06 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 1,319, Visits: 1,720
Hi All,

One of my production databases has 120 tables out of which 104 tables are using GUIDs as clustered indexes. This is a brand new database and we are still in the process of making changes. Looking at the size of the database (30MB) this is not an issue now but this is expected to grow to more than a 100 GB with in a few days time. My only concern is that use of GUIDs causes heavy fragmentation and I am thinking if we can avoid this. Per our developers requirements they cannot use identity values in place of GUIDS. In my scenario what can you think will be a best column that I can have the primary key on.

Thanks for your inputs in advance.


“If your actions inspire others to dream more, learn more, do more and become more, you are a leader.” -- John Quincy Adams
Post #1353815
Posted Tuesday, September 4, 2012 5:20 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 10:27 AM
Points: 1,319, Visits: 1,720
I will also be adding few maintenance jobs on this database that will actually purge data from this database on a daily basis and we are using Entity framework scripts for this application and those huge scripts will be doing heavy inserts and updates on some of these tables daily. So performance is what my major concern is.

“If your actions inspire others to dream more, learn more, do more and become more, you are a leader.” -- John Quincy Adams
Post #1353825
Posted Tuesday, September 4, 2012 5:59 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 4:17 AM
Points: 1,101, Visits: 5,279
Sapen (9/4/2012)
...In my scenario what can you think will be a best column that I can have the primary key on.

Thanks for your inputs in advance.

By default primary key creates clustered index.
But you create primary key with non-clustered index and create clustered index on some other column.
Post #1353837
Posted Tuesday, September 4, 2012 7:34 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 3,856, Visits: 4,996
Clustered indexes are best suited to columns most frequently used in range-based searches (e.g. MyDateColumn BETWEEN @Date1 AND @Date2).
Check all the queries run against the database to determine if there are any range-based (or exact) searches and allocate the clustered index accordingly.


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1353883
Posted Wednesday, September 5, 2012 10:35 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Monday, July 7, 2014 8:12 AM
Points: 535, Visits: 1,649
If the keys are generated by a column default, you can use NEWSEQUENTIALID.
Post #1354739
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse