Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Modify a sql query to use one of the existing index

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sureshreddy24

New User


Joined: 29 May 2009
Posts: 3
Location: hyderabad

PostPosted: Tue Mar 09, 2010 5:46 pm    Post subject: Modify a sql query to use one of the existing index
Reply with quote

how can modify a sql query to use one of the existing index in a table?
consider an example if a table is having 5 indexes and the query is using index no1 and i want it to use the index no3.
how can i do that ? can any one help on this ?
Back to top
View user's profile Send private message

sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1013
Location: India

PostPosted: Tue Mar 09, 2010 7:04 pm    Post subject:
Reply with quote

Hi Suresh,

Welcome to IBMMAINFRAMES!

Have you tried using the columns in the index as leading columns in your query.

To get better results, you have to post your query and index details.

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

New User


Joined: 31 Aug 2005
Posts: 82

PostPosted: Tue Mar 09, 2010 8:53 pm    Post subject:
Reply with quote

You should play with runstat jobs and index cardinality.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Mar 10, 2010 12:40 am    Post subject:
Reply with quote

Hello,

If the query currently uses an index, why do you want to use a different index?

What happens if you specify ORDER BY for the column(s) that make up index no3?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 10, 2010 4:35 pm    Post subject:
Reply with quote

fiddling with runstats and index cardinality is tricky. If at some point you need to drop/create the table or runstats the table again, your accesspath could change back.

possibilities:
- add "or 0=1" to the criteria on the columns of the index you don't want
- add "optimize for 1 row "
- use OPTHINTs on the bind
...
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Query on DB2 WLM stored procedures ashek15 DB2 8 Sun Feb 12, 2017 11:13 pm
No new posts setting new limit Key values for inde... srilata83 DB2 1 Fri Feb 10, 2017 9:24 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us