How common is an anti-pattern representing primary GUID keys using character data?

I recently thought about GUIDs as primary keys, and reminded me of the most egregious abuse I have ever encountered:

In this database, there were many dependencies between parents and children of Entity-Detail, such as Receipt, which had LineItems. Most Detail tables (LineItem in this case) use basic GUID keys. But instead of saving using the MSSQL type, uniqueidentifierthey were saved as 38-character strings in the form '{00000000-0000-0000-0000-000000000000}'. Oh, and they were almost always in columns nvarchar(Unicode), synchronizing a piece in 76 bytes (instead of 16 bytes for a unique identifier).

And how often did these fields come together? In almost every request in the system. Hundreds of client databases, millions of records matching this profile. Bad

The system, as far as I know, preceded SQL Server 7.0 when a unique identifier was introduced. It was simply the failure of the knowledge / research that led to this problem.

I have two questions:

  • How common is this anti-pattern in your experience?

  • It seems obvious that joining in a 76-byte Unicode string will be significantly slower than joining a 16-byte binary number with or without indexes. But can anyone give an idea of ​​what might affect performance? Suppose you index join columns in any scenario.

+3
source share
1 answer

, 76 16- , :

8k ( / / ).

, , GUID . KEY , btree ........

, , ( , 100% ). , , UNIQUEIDENTIFIER.

GUID, , , , pk , GUID - . , ..... .

+1

Source: https://habr.com/ru/post/1761416/


All Articles