473,387 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Unique Vs. Non-Unique Indexes

Guys -

I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.

Note that these columns in the unique indexes are truly unique and
don't constitute a collision hazard of any kind.

Now, I personally wouldn't use unique where non-unique would do but I
need to know what the performance impact here is.

What's it costing to use unique when non-unique would do?

DB2 8.1.8 on AIX 5.1

Bruce

Nov 12 '05 #1
4 5260
<bw********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Guys -

I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.

Note that these columns in the unique indexes are truly unique and
don't constitute a collision hazard of any kind.

Now, I personally wouldn't use unique where non-unique would do but I
need to know what the performance impact here is.

What's it costing to use unique when non-unique would do?

DB2 8.1.8 on AIX 5.1

Bruce

The only performance impact that I know of is when you insert a row or
update one of the columns. Then DB2 will have to make sure the index entry
does not already exist. But since it is adding the index row anyway when you
insert the row (or updating it if you change one of the columns in the
index) then I doubt it is much more overhead.
Nov 12 '05 #2
Guys -

I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.

Note that these columns in the unique indexes are truly unique and
don't constitute a collision hazard of any kind.

Now, I personally wouldn't use unique where non-unique would do but I
need to know what the performance impact here is.

What's it costing to use unique when non-unique would do?

DB2 8.1.8 on AIX 5.1


In some cases, queries perform better when using unique indexes.
Nov 12 '05 #3
The data model should demand UNIQUE or non-UNIQUE. If it doesn't
perhaps you have a much larger problem.

There's probably a slight performance impact when searching for a
value, because with a UNIQUE INDEX once a values is found, the database
no longer needs to search for more values. Which in this case would be
searching for one more row and not finding it. The difference should be
terribly negligable, however.

IIRC, on some platforms, DB2 demands a UNIQUE INDEX on the parent
COLUMN of a FOREIGN KEY.

B.

Nov 12 '05 #4
> What's it costing to use unique when non-unique would do?

The question would be better posed as "What's it costing to use non-unique
when unique would do?" To which the answer is loss of semantic, and non
infrequent worse performance on a range of query types.

<bw********@yahoo.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Guys -

I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.

Note that these columns in the unique indexes are truly unique and
don't constitute a collision hazard of any kind.

Now, I personally wouldn't use unique where non-unique would do but I
need to know what the performance impact here is.

What's it costing to use unique when non-unique would do?

DB2 8.1.8 on AIX 5.1

Bruce

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
0
by: amitvps | last post by:
Secure Socket Layer is very important and useful for any web application but it brings some problems too with itself. Handling navigation between secure and non-secure pages is one of the cumbersome...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.