-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Clustered Index other than Primary Key
PostPosted: Mon Sep 14, 2009 4:53 pm 
Newbie

Joined: Mon Sep 14, 2009 3:45 pm
Posts: 1
By default, NHibernate creates the clustered index on the primary key column. This is not always the most efficient behavior. In some instances it is useful to create the clustered index on a different column than the primary key column. I wonder if anyone can explain how to accomplish this.

Here is my use case.

I have several tables which each have more than one million records. For a variety of reasons, these tables use Guids for primary keys rather than integers. The Guids are not sequential and can not effectively be made sequential.

Because generated guids for new records are not guaranteed to come after the columns max value, many of the records are being inserted rather than appended. This is because the clustered index determines the physical order of the records. Since these records are less than the maximum, other records must be moved so these new records can be inserted. This can be a performance issue.

I would like to use my CreatedOn column as the clustered index--though this column is not guaranteed to be unique. (It is possible two processes could insert records at precisely the same moment.)

How I can specify that my CreatedOn column be used as my clustered index rather than the default Id column?

Thank you!


Top
 Profile  
 
 Post subject: Re: Clustered Index other than Primary Key
PostPosted: Wed Jan 12, 2011 9:52 am 
Newbie

Joined: Wed Jan 12, 2011 9:50 am
Posts: 1
any tip?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.