IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What was the purpose for which we created the index


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
barthwalsamarth

New User


Joined: 03 Aug 2006
Posts: 9

PostPosted: Mon Jun 11, 2007 7:40 pm
Reply with quote

Hi I am new to mainframes.
I have a doubt that why we need indexes.
Primary keys are used to identify unique rows but I read that index can be same for more than one row, then what was the purpose for which we created the index.

Thanks in advance!!!
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jun 11, 2007 7:49 pm
Reply with quote

Speed! Indexes are maintained in sequence and using an index avoids scanning the entire table looking for a value.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jun 11, 2007 8:14 pm
Reply with quote

Hello,

For this
Quote:
I read that index can be same for more than one row
an example might be in a "personnel" system.

Each person-id is unique, but let's say each department may have between 0 and many people assigned to it. If dept_no was a secondary key (index) a query could directly obtain all of the people assigned to that department and there would be no extra overhead traversing the entire table to return only those people assigned to the particular department(s) used in the WHERE. It could very quickly also determine that there were no people assigned to "that" department.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Cobol file using index COBOL Programming 2
No new posts DL/I status code AK for GU call using... IMS DB/DC 1
No new posts How to read unpacked field created in... DFSORT/ICETOOL 12
No new posts Add column to existing records using ... JCL & VSAM 2
No new posts choice of clustering index DB2 3
Search our Forums:

Back to Top