Since guid values will always be unique, why use a unique index. Isn't it true that when you use a unique index that slows down inserts?
Using UNIQUE constraints:
Providing uniqueness. Although the generated GUID is likely to be unique, you can easily insert the same GUID in multiple lines. Of course, you can do this by mistake, but it can even be part of your design, for example, for complex key constraints in many tables.
CREATE TABLE BookAuthors ( guid INT PRIMARY KEY, BookGuid INT NOT NULL, AuthorGuid INT NOT NULL, FOREIGN KEY (BookGuid) REFERENCES Books(BookGuid), FOREIGN KEY (AuthorGuid) REFERENCES Authors(AuthorGuid), UNIQUE KEY (BookGuid, AuthorGuid) );
. , , FOREIGN KEY, PRIMARY KEY . , FOREIGN KEY UNIQUE KEY?
CREATE TABLE Acknowledgements ( guid INT PRIMARY KEY, BookGuid INT NOT NULL, AuthorGuid INT NOT NULL, Acknowledged VARCHAR(100) NOT NULL, -- this works because of the UNIQUE constraint in BookAuthors: FOREIGN KEY (BookGuid, AuthorGuid) REFERENCES BookAuthors (BookGuid, AuthorGuid) );
.. UNIQUE - , , , UNIQUE, PRIMARY KEY FOREIGN KEY, , , - , .
, NULL.. , NULL. UNIQUE .
. . .
, CLUSTERED Index , CLUSTERED . CLUSTERED , CLUSTERED.
( CLUSTERED ) 8 , -, . , - . , , , . , GUID, GUID , , .
, - GUID 100% . , - " , GUID" , , , .
, , . SQL Server , .
, . , . SQL Server - . Kimberly Tripp , :-)
, UNIQUE INDEX GUID , / , , .
; .
, GUID.
I think you can confuse the idea of a unique constraint and a unique index a bit. Although a unique constraint may not be very useful if you are sure that the data will be unique, a unique index will create the actual “index” of this column for this table. Essentially, this gives you better performance when querying this column.
Source: https://habr.com/ru/post/1716270/More articles:Connect WCF using anonymous methods - c #How to implement Undo in a drawing program? - rasterAnt Copy task: failed to copy due to java.io.FileNotFoundException - javaDetect when UITextView has completed scrolling - iphoneCan a Windows Forms control have a Time Time property? - c #Get MySQL cell in shell script - mysqlHow to draw two separate rectangles in DirectX using the primitive type D3DPT_TRIANGLESTRIP - c ++How can I redirect test output from Perl Test :: Simple? - perlVTK Delete () and delete data - c ++Java Class.getSimpleName () and .getName () behave differently in Cacao and Sun Java - javaAll Articles