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: 1278
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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Order BY AND Index Nileshkul DB2 2 Sat Dec 31, 2016 6:33 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am


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