Today’s article is about performance issues of using guids as primary keys in your SQL tables.
Some time ago I did tests to figure out what performance penalty of using guids as primary keys would be. I tested insert and select statements on 10.000, 50.000, 200.000 and 1.000.000 records. If your problem is larger you will have to do your own measurements.
Here are my conclusions.
For select statements performance penalty is linear and can be ignored.
For insert statements it is different. Performance penalty grows exponentially. Following is the graph showing my test results.
I assume that generating new guid requires much more math then simply increasing integer by one. Writing 16 bytes is more expensive then writing 4.
Conclusion: it makes sense avoiding guids as primary keys if performance of insert statements is critical to your system.
Categories sql
0 comment(s) :
Post a Comment