Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Confusion b/w index and subscript Deepak kumar25 Mainframe Interview Questions 7 Thu Aug 31, 2017 6:50 am
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us