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

Multiply indexes for one query.


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

New User


Joined: 07 Apr 2010
Posts: 7
Location: Poland

PostPosted: Thu Jul 01, 2010 1:44 pm
Reply with quote

Does DB2 for z/OS use multiply indexes for query, or only one that is probably most efficient. If DB2 uses only one index, is there a way to use multiply?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Thu Jul 01, 2010 4:21 pm
Reply with quote

Hi Larret, Welcome to IBMMAINFRAMES.

Answer is "it depends" on the optimizer and the available statistics.

In General,
Multiple Column Indexes are efficient for equality. And multiple Indexes are more efficient on comparisons.

Sushanth
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Jul 01, 2010 4:36 pm
Reply with quote

The answer to this single line triple-question can fill a redbook.
the answers are : sometimes sometimes sometimes.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jul 01, 2010 5:48 pm
Reply with quote

The main purposes of indexes are:

    To improve performance. Access to data is often faster with an index than without.
    To ensure that a row is unique. For example, a unique index on the employee table ensures that no two employees have the same employee number.
    To cluster the data.
    To determine which partition the data goes into.
    To provide index-only access to data.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jul 01, 2010 5:57 pm
Reply with quote

I'll start with,probably, what you want to listen - in a way, adding indexes to a table slows down insert and updates to that table, why? Because, each of these changes have to be applied not only to the actual data but the index pages also. And it will surely (should be acceptable, right?) eats up more disk space. If your database is small and your tables have few indexes on them, then adding a new index, which might not be required at all though, will probably not be noticed on modern fast machines. If your data is huge, very huge, your table is heavily indexed or you are runing on old machnines (actuators are not that good) then sometimes you have to make intelligent choices about which indexes are the most important to the performance of your program. The indexes for seldom-used queries sometimes have to be removed for the sake of more important indexes and the overall performance of updates to the table.

Because action queries on a table are affected by the number of indexes that table has, a table that is updated constantly by multiple users may not be able to have as many indexes as one that stays very static - so yes, as others have siad - yep, it depends.
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top