SQL Server: ~ 2000 heap tables all using GUID Uniqueidentifier - possible clustered indexing?

I just took a database that contains about 2200 tables. More than 2000 of them do not have a clustered index (some do not have indexes at all).

All tables were configured to use a GUID as a unique identifier.

Just by looking at query plans, I see that a lot of table scans are going on. Most searches use a unique identifier for the search.

I am wondering if it is better to have a clustered index in a GUID than not have a clustered index at all. I assume that a clustered index in a 16 byte column will inevitably lead to fragmentation.

I could probably group them into other columns, but most search queries tend to search or join through GUIDS.

Any advice would be greatly appreciated. I have never seen so many GUIDs!

+4
source share
3 answers

In general, I would recommend having a column identityas a primary key and using it for clustering. It is also the best choice for joins.

Why? First, identification keys are usually shorter than unique identifiers. Thus, links and foreign key indexes are smaller.

, insert " " . GUID . , , GUID ( ).

2000 , , . , newsequentialid().

+4

GUID , :

  • ;
  • , ;

3 , :

+4

:

-, DMV, , ( ), , , . , 2200 , .

, , guid , , . - .

, fillfactor, , , (OLTP DW / )

, / , , . guid. , () .

-guid-, (, ) . .

+1

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


All Articles