Home » RDBMS Server » Performance Tuning » Need help with tuning
Need help with tuning [message #519955] Wed, 17 August 2011 13:32 Go to next message
naveenreddy
Messages: 10
Registered: August 2011
Junior Member
The below query is taking more than 5minutes to return the data for any criteria.

The big tables are

SECURITY_POSITION_SUMMARY -- 60Million
WEB_TEAM_X_ACCOUNT_BM -- 26Million

and the rest of those are small tables

All the indexes are in place and I have tried with few hints but this query is slow.

Can anyone please help?

WITH REPS
       AS (SELECT   DISTINCT REP_SET.FILTER_TOKEN
             FROM   (SELECT          /*+ INDEX (wdsd WEBDATASETDTL_PK_TEAM) */
                           DISTINCT
                              WDSD.DATA_SETTING_ID, WDSD.FILTER_TOKEN
                       FROM   WEB_DATA_SETTING_DETAIL WDSD,
                              (SELECT   INST_QUERY_ID,
                                        NVL (Y.DATA_SETTING_ID,
                                             X.DATA_SETTING_ID)
                                           DATA_SETTING_ID
                                 FROM   WEB_INSTANTIABLE_QUERY Y,
                                        (SELECT   DATA_SETTING_ID
                                           FROM   WEB_DATA_SETTING
                                          WHERE   BROKER_ID = :B1
                                                  AND DEFAULT_YN = 'Y') X
                                WHERE   INST_QUERY_ID = :B2) WIQ
                      WHERE   WIQ.DATA_SETTING_ID = WDSD.DATA_SETTING_ID)
                    REP_SET),
    ENTIT AS (SELECT   WTXA.ACCOUNT_ID
                FROM   WEB_TEAM_X_ACCOUNT_BM WTXA, WEB_BROKER_X_TEAM WBXT
               WHERE   WBXT.BROKER_ID = :B1 AND WTXA.TEAM_ID = WBXT.TEAM_ID),
    WDT
       AS (SELECT   DATABASE_TYPE AS PROD_TYPE_ID, DESCR
             FROM   WEB_DATABASE_TYPE
            WHERE   DATABASE_TYPE IN
                          (SELECT   DATABASE_TYPE
                             FROM   WEB_DATABASE_TYPE_MAP
                            WHERE   DATABASE_TYPE_SET_ID IN
                                          (SELECT   WGS.VALUE
                                             FROM   WEB_GROUP_SETTING WGS
                                            WHERE   WGS.SETTING_ID = 654
                                                    AND WGS.GROUP_ID IN
                                                             (SELECT   GROUP_ID
                                                                FROM   WEB_GROUP
                                                               WHERE   INSTITUTION_ID =
                                                                          :B3))))
  SELECT   *
    FROM   (  SELECT   WDT.DESCR AS PROD_TYPE,
                       WDT.PROD_TYPE_ID,
                       COUNT (DISTINCT RSSUM.SEC_NO) AS NO_SEC,
                       SUM (RSSUM.MARKET_VALUE) TOTAL_ASSETS,
                       SUM (
                          NVL (RSSUM.MTD_COMMISSION, 0) + NVL (RSSUM.MTD_FEE, 0)
                       )
                          MTD_COMM_FEE,
                       SUM (
                          NVL (RSSUM.YTD_COMMISSION, 0) + NVL (RSSUM.YTD_FEE, 0)
                       )
                          YTD_COMM_FEE
                FROM   (SELECT    /*+ index (sps SEC_POS_SUMMARY_I_ACT_ID ) */
                              SPS.SEC_ID
                                    SEC_NO,
                                 SPS.MARKET_VALUE,
                                 SPS.MTD_COMMISSION,
                                 SPS.YTD_COMMISSION,
                                 SPS.MTD_FEE,
                                 SPS.YTD_FEE,
                                 SPS.PROD_TYPE_ID PROD_TYPE_ID
                          FROM   SECURITY_POSITION_SUMMARY SPS
                         WHERE   SPS.ACT_ID IN
                                       (SELECT   SM.ACCOUNT_ID
                                          FROM   REPS, WEB_ACCOUNT_QRY_FILTER SM
                                         WHERE   REPS.FILTER_TOKEN =
                                                    SM.FILTER_TOKEN)
                                 AND EXISTS (SELECT   '1'
                                               FROM   ENTIT
                                              WHERE   ACCOUNT_ID = SPS.ACT_ID))
                       RSSUM,
                       WDT
               WHERE   RSSUM.PROD_TYPE_ID(+) = WDT.PROD_TYPE_ID
            GROUP BY   WDT.DESCR, WDT.PROD_TYPE_ID)
ORDER BY   PROD_TYPE ASC

[RL: Added code tags]

[Updated on: Mon, 22 August 2011 08:17] by Moderator

Report message to a moderator

Re: Need help with tuning [message #519958 is a reply to message #519955] Wed, 17 August 2011 14:20 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
For any peformances question, please read http://www.orafaq.com/forum/mv/msg/84315/433888/102589/#msg_433888 and post the required information.

And Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Regards
Michel

[Updated on: Wed, 17 August 2011 14:21]

Report message to a moderator

Previous Topic: 2 design alternatives, passing natural key as meaningful foreign key
Next Topic: performance tuning PROBLEM
Goto Forum:
  


Current Time: Fri Nov 22 01:14:39 CST 2024