Supporting material for the article The Cost of GUIDs as Primary Keys (InformIT)

2002-03-07, Jimmy Nilsson

Introduction

This document will very shortly describe the supporting material to the article about GUID overhead when used as primary keys (at InformIT). The document assumes that you have read that article.

 

The code is NOT supported and NOT of production quality! Error handling code has been excluded for brevity, and so on... Use the code for inspirational purposes only! The code is tested with SQL Server 2000.

 

Disclaimer

JNSK below means both Jimmy Nilsson and JN SystemKonsult AB.

 

ANY USE BY YOU OF THE SOFTWARE IS AT YOUR OWN RISK. THE SOFTWARE IS PROVIDED FOR USE "AS IS" WITHOUT WARRANTY OF ANY KIND. JNSK AND INFORMIT DISCLAIM ALL WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. JNSK AND INFORMIT ARE NOT OBLIGATED TO PROVIDE ANY UPDATES TO THE SOFTWARE.

 

NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall JNSK or INFORMIT be liable for any damages whatsoever (including, without limitation, incidental, direct, indirect special and consequential damages, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use or inability to use this product, even if JNSK or INFORMIT have been advised of the possibility of such damages.

 

Use of this software signifies your understanding of and agreement to these conditions.

 

ZIP

The zip-file includes a script to add tables and sprocs to a test database. The zip also includes test drivers to run the different tests.

 

You can download the zip here.

 

Get started

Run the script called db.sql in a test database (preferably a newly created one). Then you have the needed tables and sprocs.

 

Then you can run the different test drivers. For example, the td - INTa.sql file is a test driver for inserting orders to the INT tables.

 

Its important to understand that, for example, td - INTb.sql only outputs statements that can be pasted into td - INTb-part2.sql and td - INTc-part2.sql. (In the case latter case you also have to do a search and replace after the paste, see the comment in the testdriver.)

 

Note

To see interesting effects you have to have MANY thousands orders in your tables. See the article for further information.

 

Also note that the GUID-tables in the version in the zip use identities as a trick (not very successful) to overcome the GUID throughput limitation. Feel free to experiment without those columns too of course.

 

Good luck!