Unix Technical Forum

indexes on null columns

This is a discussion on indexes on null columns within the DB2 forums, part of the Database Server Software category; --> What are the issues regarding creating a index on a nullable column? For example there are 3 nullable columns. ...


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 09:58 AM
Kris Koschik
 
Posts: n/a
Default indexes on null columns

What are the issues regarding creating a index on a nullable column?

For example there are 3 nullable columns. I want to add one index on
each of the 3 nullable columns:

Table1 : 100,000 rows

id bigint not null primary key
empid1 bigint nullable null 9/10 of the time
empid2 bigint nullable null 1/3 of the time
empid3 bigint nullable null 1/3 of the time

thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 09:59 AM
Douglas Doole
 
Posts: n/a
Default Re: indexes on null columns

As far as an index is concerned, a NULL is treated like any other value.
(Yeah, I know NULL is really the absense of a value, but index manager
failed the basic relational concepts course ;-)

Given your stats, you won't be able to create a unique index on the columns
since a unique undex will only allow one NULL. With a non-unique index, all
the NULLs will be gathered into a single index key (with lots of associated
RIDs).

--
__________________________________________________ ___________________
Doug Doole
DB2 Universal Database Development
IBM Toronto Labs

DB2 UDB v8.1 is available for AIX, HP, Linux, Solaris and Windows
http://www-3.ibm.com/software/data/db2/udb/v8/

Visit the DB2 UDB and DB2 Connect Online Support site at:
http://www.ibm.com/software/data/db2...s2unix/support
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 10:00 AM
Gary Rempel
 
Posts: n/a
Default Re: indexes on null columns

On DB2 for OS390 you can create a UNIQUE WHERE NOT NULL

Douglas Doole wrote:

>As far as an index is concerned, a NULL is treated like any other value.
>(Yeah, I know NULL is really the absense of a value, but index manager
>failed the basic relational concepts course ;-)
>
>Given your stats, you won't be able to create a unique index on the columns
>since a unique undex will only allow one NULL. With a non-unique index, all
>the NULLs will be gathered into a single index key (with lots of associated
>RIDs).
>
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 10:02 AM
Paul Vernon
 
Posts: n/a
Default Re: indexes on null columns

"Douglas Doole" <doole@ca.ibm.com> wrote in message
news:bf6e92$2tr$1@hanover.torolab.ibm.com...
> As far as an index is concerned, a NULL is treated like any other value.
> (Yeah, I know NULL is really the absense of a value, but index manager
> failed the basic relational concepts course ;-)


I'ld say it passed. It was SQL that flunked.

;-)

Regards
Paul Vernon
Business Intelligence, IBM Global Services


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:13 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com