Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 Performance Tuning
»
unique versus non-unique index in terms of...
unique versus non-unique index in terms of performance
Rate Topic
Display Mode
Topic Options
Author
Message
Mani-989491
Mani-989491
Posted Friday, February 06, 2009 6:29 AM
SSC Rookie
Group: General Forum Members
Last Login: Friday, August 03, 2012 1:20 PM
Points: 48,
Visits: 98
In terms of performance which one should be created between unique and non-unique index. Let us say I want to make a Non clustered index on columns which is idenetity column. As I alredy know this columns value is unique so if I create a non-unique index will that have any significant performance over the unique index.
My concern is as unique index will check for any duplicate existing row for every new entry and I have some 70000 records added to the table every day so will my upload into the table will take more time after I create this unique index. Also which index will have better query performance.
Post #651562
Grant Fritchey
Grant Fritchey
Posted Friday, February 06, 2009 8:08 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 13,381,
Visits: 25,168
It depends on the queries being run. The optimizer will take into account when an index is unique and it can improve performance, but it really does depend on the query. It might not affect things at all.
It will slow down inserts slightly, but probably not enough to notice. It doesn't have to check everything single record against every other record. It's going to use the index itself for the check which will be quite fast.
In general, if you've determined that an index will help and the data being indexed is going to be unique, I'd say go ahead and make it a unique index. It won't cost much and you will receive benefits.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #651695
Mani-989491
Mani-989491
Posted Friday, February 06, 2009 8:49 AM
SSC Rookie
Group: General Forum Members
Last Login: Friday, August 03, 2012 1:20 PM
Points: 48,
Visits: 98
Thanks Grant
Post #651754
Ninja's_RGR'us
Ninja's_RGR'us
Posted Friday, February 06, 2009 9:04 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 2:27 PM
Points: 21,357,
Visits: 9,537
I'd go the complete opposite. If the data requiresa unique index (for data quality), then go ahead and create the index. I wouldn't do a unique index just because it might go faster and not consider wheter or not it could bug the applications using it.
Post #651767
Grant Fritchey
Grant Fritchey
Posted Friday, February 06, 2009 9:08 AM
SSChampion
Group: General Forum Members
Last Login: Today @ 9:37 AM
Points: 13,381,
Visits: 25,168
Oh no, if it's going to bug the apps, then clearly the data is not guaranteed unique. I'm just saying if the data is going to be unique, there's no reason to not make the index unique and several reasons to make it that way.
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #651774
Vijaya Kadiyala
Vijaya Kadiyala
Posted Monday, February 09, 2009 9:05 AM
SSCommitted
Group: General Forum Members
Last Login: Monday, October 25, 2010 6:09 AM
Points: 1,621,
Visits: 409
I Agree with Ninja's decision. If the data requires to have Unique Index then we should have Unique Index. In this world anything can happen with Data Quality. So always impose contraints on this to avoid any future Data Quality Issues.
Thanks -- Vijaya Kadiyala
http://dotnetvj.blogspot.com
Thanks -- Vijaya Kadiyala
www.dotnetvj.com
SQL Server Articles For Beginers
Post #652904
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.