Posts

Showing posts with the label Composite index

SQL Server, A little about composite indices and a little about the relative statistics ..

Image
Hi Guys, Today a short midweek post!   We will talk about the composite index and statistics . Nothing particularly profound, but any information we can learn, I'm sure will be useful in the future. Enjoy!   Composite index What is a composite index?  Well, a composite index is simply an index that defined on more than one column . For example. Upon the following table ORDTES CREATE TABLE ORDTES (Id INT IDENTITY (1,1) PRIMARY KEY CLUSTERED , DOC_YEAR int , DOC_NUMBER int , CUSTOMER_NAME varchar (80) );   We can define an index on both the columns DOC_YEAR, DOC_NUMBER: CREATE INDEX IDX_ORDTES_DOC_YEAR_DOC_NUMBER ON ORDTES (DOC_YEAR, DOC_NUMBER)     This means that if I search for a specific pair of DOC_YEAR, DOC_NUMBER values I should arrive directly with a seek of the searched record. Is this true? Yes, but let's see more in detail by taking a look at the statistics ... we will find out interesting things .. Statistics Statistics are critic...