MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Number of index

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Thu Mar 17, 2011 11:55 am    Post subject: Number of index Reply with quote

I konw that one should limit the number of indexes on a table. If I have queries that reference different columns on a table:
Code:

query 1:  WHERE COLA = 'X'
query 2:  WHERE COLB = 'S'
query 3:  WHERE COLC = 'X1'
query 4:  WHERE COLA = 'W' and COLC = 'X2'
query 5:  WHERE COLB = 'T' and COLC = 'X5'

Number of distinct values in: COLA = 8, COLB = 5, COLC = 10

Would a single inedx with COLA, COLB and COLC be sufficient? If one index is sufficient, what should be the clolumn sequence in the index (e.g. COLB with the least distinct value should be first)?
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Mar 17, 2011 2:36 pm    Post subject: Reply with quote

I beleive if you want to use index for all these queries then first three would need different indexes, so you got at least three.
_________________
Regards,
Diba
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Thu Mar 17, 2011 2:50 pm    Post subject: Reply with quote

danm wrote:
Number of distinct values in: COLA = 8, COLB = 5, COLC = 10


Danm,

Do you really need an index for such low volume of data?

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Thu Mar 17, 2011 3:05 pm    Post subject: Reply with quote

Kolusu,

Don't I need index on a table that contains over 400,000 rows?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12382
Topics: 75
Location: San Jose

PostPosted: Thu Mar 17, 2011 3:23 pm    Post subject: Reply with quote

danm wrote:
Kolusu,

Don't I need index on a table that contains over 400,000 rows?


You would need an index but the counts you have shown earlier doesn't translate to 400k records.

In any case I would suggest reading this excellent article about Index design which will give you a better idea

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Mon Mar 21, 2011 1:04 pm    Post subject: Reply with quote

Kolusu,

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group