I use Fluent-NHibernate (with automation) to create my tables, but would like to select a different clustered index than the ID field, which is used by default. How to create clustered indexes with Fluent NHibernate in a field other than the default field of the main field?
The main reason for this is simple. I use Guides for my primary key fields. By default, NHibernate creates clustered indexes in primary key fields. Because guides are usually not sequential, clustering in the primary key field causes performance problems.
As we all know, adding records at the end of a table is much cheaper than inserting records into a table. In addition, the records in the table are physically stored in the order of the elements in the cluster index. Since the guides are somewhat βrandomβ and not sequential, new Guides can be generated that are less than the value of other identifiers already in the table, which leads to the insertion of tables, and not to the addition.
To minimize this, I have a column called CreatedOn that is of type DateTime. I need the table to be clustered in this CreatedOn column so that all new records are added, not inserted.
Any ideas on how to do this are welcome !!!
Note. I understand that I can use Sequential Guids, but I prefer not to go this route for security reasons.
Note. I still don't have an answer to this post, but I have a few ideas that I'm thinking about right now.
Using NHibernate without Fluent, I think it's possible to create clustered indexes directly in NHibernate. I still don't know enough about NHibernate to know how to do this. I'm just pretty (almost almost absolutely) sure that this can be done.
Fluent-NHibernate is used to enable a method of setting attributes (such as a clustered index) on an SQL object until recently rewritten. Now this option has disappeared. I would probably ask if this option is available. If so, I could probably use this to set up a clustered index.
Fluent-NHibernate , . , , , .
SQL script . . . , NHibernate "" ? 2. NHibernate, , ? , . . SQLServer2008 MySQL. NHibernate , . , .
, , IPropertyInstance, , Index, . , , . , . , Fluent-NHibernate.