c# - SQL Server - Guid VS. Long -


So far I have c # "Guid = Guid.NewGuid ();" The method to generate a specific ID that can be stored in some of my SQL Server database tables as an ID field, which Linq to SQL has used to inform me that for indexed reasons, using a GUID Have a bad idea and should use automatic incremental length: Will the speed of my database transaction be used? If so, how do I go about creating unique IDs that are of that type?

Regards,

Both sides and cons are entirely dependent That's how you use those cases.

Just above the bat, if you need those identifiers that can work in many databases, then you need a GUID. Some tricks with long (manually separate each database into different seeds / Increment), but they do not scale well.

As far as the index goes, the index will be much better inserted. The cluster (clustered by the default primary key, but it can be modified for your table), since every entry There is no need to reorganize the table after.

As far as concurrent inserts are concerned, long (identity) columns will be slowed, then the GUID - Identity column generation requires a series of unique locks to ensure that only one The row is the next sequential number. With many users putting multiple rows at all times in an environment, this could be a performance hit. The GUID generation is fast in this situation.

According to the collection, a GUID takes place instead of one long (8 bytes vs. 16). Although this depends on the overall size of your line, if 8 bytes are going to make a noticeable difference in how many records fit in one leaf, and thus the number of leaves removed from the disc during the average request.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -