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

DB2 Query Optimisation


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

New User


Joined: 02 Sep 2006
Posts: 31
Location: Mumbai

PostPosted: Thu Jul 09, 2009 4:48 pm
Reply with quote

Hi below is my query...it is taking a lot of time...can anyone suggest ways to optimise this query

select a,b,c,d
from view1
where digits(a*10 + b) in (:t1, :t2, :t3)
order by a,b,c,d

Thanks.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Thu Jul 09, 2009 4:53 pm
Reply with quote

Try to avoid calculations in the query. It may yield better results if you break it down to two queries.
Back to top
View user's profile Send private message
rajnikantvanpratiwar

New User


Joined: 01 Jul 2009
Posts: 5
Location: Pune

PostPosted: Thu Jul 09, 2009 5:00 pm
Reply with quote

check once whether you are using index part in you query or not and if not then try using it so tht query retrieves data in fast way....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 09, 2009 5:19 pm
Reply with quote

why not make t1, t2 and t3 non-char datatype?
the digits scalar function should be removed.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jul 09, 2009 7:34 pm
Reply with quote

Try not to use calculations in where clause ...

Code:


select a,b,c,d from (
select a,b,c,d, digits(a*10 + b) as s
from view1 ) as a
where s in (:t1, :t2, :t3)
order by a,b,c,d

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