July 8, 2014 at 5:49 am
Friends,
Table Structure:
CREATE TABLE MappingTable (
[Column1] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
[Column2] [int] NOT NULL,
[Column3] [int] NOT NULL,
[Column4] [bit] NULL,
[Column5] [datetime] NULL,
[Column6] [datetime] NULL,
CONSTRAINT [PK_MappingTable] PRIMARY KEY NONCLUSTERED
(
[Column2] ASC,
[Column3] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
Now, my question is , I think to alter the table to PRIMARY KEY CLUSTERED, could you please suggest me, is there any difficulties or performance issue because of this changes.
Thanks,
Prabhu
July 8, 2014 at 6:06 am
I hope it is not Live system as you have not mentioned about it.
You need to drop primary key & add it again with CLUSTERED clause as below
ALTER TABLE mappingTable DROP CONSTRAINT [PK_MappingTable]
ALTER TABLE mappingTable ADD CONSTRAINT [PK_MappingTable] PRIMARY KEY CLUSTERED
(
[Column2] ASC,
[Column3] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
It will create Clustered Index. The clustered index has an advantage over all other indexes: since it always includes all columns, is always covering. Therefore queries that can leverage the clustered index certainly do not need to use lookups to satisfy some of the projected columns and/or predicates.
Thanks
July 8, 2014 at 6:11 am
Hardy21 (7/8/2014)
The clustered index has an advantage over all other indexes: since it always includes all columns, is always covering. Therefore queries that can leverage the clustered index certainly do not need to use lookups to satisfy some of the projected columns and/or predicates.
Yes, but if queries cannot leverage the clustered index, you are still doing a full table scan.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
July 8, 2014 at 6:17 am
Koen Verbeeck (7/8/2014)
Hardy21 (7/8/2014)
The clustered index has an advantage over all other indexes: since it always includes all columns, is always covering. Therefore queries that can leverage the clustered index certainly do not need to use lookups to satisfy some of the projected columns and/or predicates.Yes, but if queries cannot leverage the clustered index, you are still doing a full table scan.
Thats is correct. It depends on how you query the data.
Thanks
July 8, 2014 at 8:07 am
Thanks to Hardy & Koen for your immediate replies.
@Hardy,
yes it is not a live server as of now, but I am planning to implement the changes to the live server whereas it should be
tested in various stages
"Development Integration Server" (DIS)
"System Integration Server" (SIS)
"Performance Testing Server" (PTS)
Finally to the "Live Server" (Live)
@Koen,
yes, as of now since that is a mapping table and Column2 and Column3 refers to each Master Table respectively
and the values in these columns are the IDs of the appropriate master tables, thus these two columns has the vast usage and there is no point to think about "out of Leverage"
Thanks for all your Inputs, I would test this with my DIS first, then let you know for sure..
Cheers,
Prabhu
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply