Sunday 15 June 2014

sql - Should a table's primary key be a column in another index for that table? -


Assuming that I have such a table ID is the primary key, so I know that it gets an index on it .

  Make Tabs Employer (ID is not VARCHAR (64), NTIIIiIiIERI VARAR (64) Faucet, Name VARCHAR 64) Faucet, StateCode VARCHAR (64) Faucet, ZIPDrop VARCHAR (64) No, zero , Address 1 VARCHAR (64), address 2 VARCHAR (64) No, zero, City VARCHAR (64) No, job title VARCHAR (64)   

I'm adding Yes, no, zero, with Constant PK_Employer_Id Primary Key Cluster (ID ASC) (PAD_INDEX = closed, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) Another index to help Oj (though really no reason to include why not relevant) What ID as one of the columns in the index (primary key) in? I have SQL experts say that this is a waste of space, because the index can initially contain some kind of primary key. [Employer] on [Employer] [[EntityId]] [idxEmployerByNameAddress1City], [ID], [name], [address1], [city])

If your secondary index does not start with the primary key column (s), then the primary key is irrelevant to the secondary index. On the other hand, if your index is based on the first two columns, as it seems that there may be a case here, then there is no point in placing the column more in the column - it just erases the location in the index.

No comments:

Post a Comment