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

Performance issue with DB2 query


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

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Wed Nov 05, 2008 12:45 pm
Reply with quote

From Explain ..
when I see index.. it's showing XP4PD00.
I think this query using this index.
can we use XP4PD02? how?
Back to top
View user's profile Send private message
vaishali tambe

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Wed Nov 05, 2008 12:54 pm
Reply with quote

Hi Manohar,
PIC clouse in working storage is:

WS-TSQ-PAYID PIC S9(10)V USAGE COMP-3.
WS-TSQ-RUN-ID PIC S9(09) COMP.
WS-TSQ-TIN-FORMAT-CD PIC X(1).
WS-TSQ-TIN-NUM PIC S9(9) USAGE COMP.
Back to top
View user's profile Send private message
vaishali tambe

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Wed Nov 05, 2008 1:36 pm
Reply with quote

And these declarations are equal to cobol declaration for table P4PCLM in DCLGEN.
So i think it's not a problem.
icon_sad.gif
Back to top
View user's profile Send private message
vaishali tambe

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Wed Nov 05, 2008 1:40 pm
Reply with quote

Hi Suresh,
I tried running 2 diffrent queries as given above.
no increase inperformance.

icon_sad.gif
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Wed Nov 05, 2008 9:14 pm
Reply with quote

Hi Vaishali,

You can query SYSIBM.SYSINDEXES to get the CLUSTERRATIO for the index. Please let us know the value?

If the CLUSTERRATIO for the index XP4PD02 is very less, please talk to your DBA to execute the RUNSTAT utility for the table. Once it is done, you can see the latest CLUSTERRATIO (should be increased) for each index.

And also, please request your DBA to rebind your program (After executing RUNSTAT), run EXPLAIN again and let us know if there are improvements?
Back to top
View user's profile Send private message
vaishali tambe

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Thu Nov 06, 2008 10:04 am
Reply with quote

Hi Suresh,
Details for index : XP4PD00
Max. ds piece size (KB) : 2097152
Clustering ratio : 86
Is it actually clustered: No

Details for index : XP4PD02
Index type : Type 2 index
Max. ds piece size (KB) : 2097152
Clustering ratio : 0-Not gathere

I don't know which index using this query.[/img]
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Nov 06, 2008 2:22 pm
Reply with quote

Hi Vaishali,

First of all you need to see which INDEX is being used by your SQL ...you said from EXPLAIN the query is using XP4PD00 which is actually good as it is unique ...if you want to change it to other use WHERE 0=1 in you WHERE clause so as to confuse DB2 ... Now you SQL is a very simple one ...what you can do is put the most restrictive columns first in your WHERE clause ...by restrictive i mean the one for which there will be least number of different data ....

Do a RUNSTATS and maybe a REORG ...
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Thu Nov 06, 2008 8:52 pm
Reply with quote

Hi Ashimer,

If we use 0 = 1 in the WHERE Clause, the query will return SQLCODE 100.. Am I correct?

I executed a query with WHERE 0 = 1 from one of my tables and got SQLCODE 100.

Hi Vaishali,

As per your query, if it uses XP4PD02 index, it would give better results in performance.

Since the CLUSTERRATIO for the Index XP4PD02 is 0, please talk to your DBA to run the REORG and RUNSTAT utility for this table and check whether the query is using the above index.

Please request you DBA to REBIND your program which has the above query and check the performance.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Nov 06, 2008 9:01 pm
Reply with quote

Sorry use " OR 0 = 1 "
Back to top
View user's profile Send private message
tambe vaishali

New User


Joined: 25 Oct 2008
Posts: 1
Location: India

PostPosted: Mon Nov 17, 2008 6:05 pm
Reply with quote

Hi,

In my query
Code:
EXEC SQL                                             
        SELECT COUNT(*),                                 
               SUM(P4PCLM_ALWD_AMT)                     
          INTO :WS-TSQ-CLMNO,                           
               :WS-TSQ-CLMAMT                           
          FROM P4PCLM                                   
         WHERE P4PPRVRN_SEQ_NO   = :WS-TSQ-PAYID         
           AND P4PRUN_ID         = :WS-TSQ-RUN-ID       
           AND P4PCLM_IDFMT_CD   = :WS-TSQ-TIN-FORMAT-CD
           AND P4PCLM_LCPITIN_ID = :WS-TSQ-TIN-NUM       
           WITH UR                                       
    END-EXEC 


When I comment out condition AND P4PRUN_ID = :WS-TSQ-RUN-ID ... then it's working fine.... icon_smile.gif
But it's a primary key.. it must be there.... don't know whats happening in db2...
Back to top
View user's profile Send private message
Suresh Ponnusamy

Active User


Joined: 22 Feb 2008
Posts: 107
Location: New York

PostPosted: Tue Nov 18, 2008 1:52 am
Reply with quote

Quote:

When I comment out condition AND P4PRUN_ID = :WS-TSQ-RUN-ID ... then it's working fine....


That means your requirement is satisfied or it is running fast?. If the requirement is satisfied then you can use the above one. or if it is taking less time after removing the key, then we need to analyse further.
Back to top
View user's profile Send private message
Bharath Bhat

Active User


Joined: 20 Mar 2008
Posts: 283
Location: chennai

PostPosted: Tue Nov 18, 2008 9:03 am
Reply with quote

Quote:
When I comment out condition AND P4PRUN_ID = :WS-TSQ-RUN-ID ... then it's working fine....


I guess the index is taking more time. Try adding OR 0=1 in the where clause as Ashimer said. This will avoid the use of index.
Back to top
View user's profile Send private message
vaishali tambe

New User


Joined: 16 Apr 2008
Posts: 24
Location: pune

PostPosted: Wed Nov 19, 2008 10:22 am
Reply with quote

Hi,

I tried using "Or 0 = 1 " in my query and using AND P4PRUN_ID = :WS-TSQ-RUN-ID condition.
It's still getting time... icon_sad.gif
Any othere way to change index during run-time??
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 Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
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 exploiting Z16 performance PL/I & Assembler 2
No new posts Query on edit primary command CLIST & REXX 5
Search our Forums:

Back to Top