If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL Tuning -- VERY URGENT

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-06, 10:20
dba_udb dba_udb is offline
Registered User
 
Join Date: Mar 2005
Posts: 73
SQL Tuning -- VERY URGENT

OS: AIX UDB 8.2

All,

I am having some tough time with the SQL tuning. I have a couple of Reporting SQLs which are performing very slow.

I took the explain of the SQLs . But I can't understand it .

I see a table is using and TBSCAN , even though it has indexes. what could be the raason.

How do i change HSJOIN to NLJOIN.


I See a few more TBSCANs after the SORT operation. How do i figure out which is causing TBSCAN in this scenario.




thanks
Attached Files
File Type: zip first.zip (6.5 KB, 31 views)

Last edited by dba_udb; 10-10-06 at 16:07.
Reply With Quote
  #2 (permalink)  
Old 10-04-06, 10:43
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
How about posting the SQL? Include what your intent of the SQL.

Andy
Reply With Quote
  #3 (permalink)  
Old 10-04-06, 11:17
dba_udb dba_udb is offline
Registered User
 
Join Date: Mar 2005
Posts: 73
Here is the SQL.





1) ois.ord_item_id has an index . But it is not being used. This index was created on two columns one being ois.ord_item_id.
2) Is this a good idea to create indexes on all the columns of GROUP by function.
3) I see few TBSCANS after a sort operation in Graph. What does it mean.

Can some one refer me good documentation for understanding Visual grapsh.

Last edited by dba_udb; 10-05-06 at 10:52.
Reply With Quote
  #4 (permalink)  
Old 10-04-06, 11:40
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Tutorial on Visual Explain:

http://users.sdsc.edu/~jrowley/db2/V...l%20explain%22

Can you post the DDL for the tables? Have you done RUNSTATS in the tables?

Andy
Reply With Quote
  #5 (permalink)  
Old 10-04-06, 13:59
Nageswaran Nageswaran is offline
Registered User
 
Join Date: Jul 2002
Posts: 48
HSJOIN is better than NSLOOP JOIN. If you have two big table i will prefer to have HSJOIN. Only problem is for doing HSJOIN we need more memory. Apart from that check the predicates of all the HSJOIN, if you create the index on that it might improve the performance. Moreover try to do runstats on all the tables with indexes all and distribution which might also improve the performance.
Reply With Quote
  #6 (permalink)  
Old 10-04-06, 20:08
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You may also want to consider posting the explain plan and the statistics ... output of db2exfmt with the -g option may do good ...

Having a quick look at your query (at 2 am ;-) ) , these are my observations :

a) You have a couple of outer joins ... So, no wonder you get tablescans

b) I think it may be a good idea to 'apply' some of your conditions in the where clause before you do the left outer join (or may be, db2 already does this optimization)

For your questions :
1) previous paragraph answers this
2) no, given that you have too many columns in the group by.
3) the sorted table is being read

Nageswaran, in my opinion, trying to make your NSLOOP joins HSJOINS or vice-versa is not advisable ... Many people have an opinion that Nested-Loop joins are bad, which I generally differ with .. They get really bad if the join columns are not indexed ... To me HSJOINs on base tables mean that there is a scope for index improvements ...

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 10-05-06, 02:16
istikhar istikhar is offline
Registered User
 
Join Date: Sep 2006
Posts: 19
The link below may provide some details

http://publib.boulder.ibm.com/infoce...n/c0005414.htm

Istikhar
Reply With Quote
  #8 (permalink)  
Old 10-10-06, 16:05
dba_udb dba_udb is offline
Registered User
 
Join Date: Mar 2005
Posts: 73
Satya Ram . Thanks for u r reply.

Currently i am working on other SQL , which is taking a longer time than usual time.


I am attaching the explain out put of it here. Damn these sqls are killing me .
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On