Home » RDBMS Server » Performance Tuning » Tuning help needed (Oracle 11.1.0.7.0)
Tuning help needed [message #522446] |
Fri, 09 September 2011 13:04 |
|
naveenreddy
Messages: 10 Registered: August 2011
|
Junior Member |
|
|
/* Formatted on 9/8/2011 1:42:10 PM (QP5 v5.115.810.9015) */
WITH replist
AS (SELECT DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT
wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = 48270
AND DEFAULT_YN = 'Y') X
WHERE inst_query_id = 1385776) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id)
rep_set),
actlist
AS (SELECT /*+ use_hash(wbxt wtxa) */
account_id
FROM web_team_x_account wtxa, web_broker_x_team wbxt
WHERE wbxt.broker_id = 48270 AND wtxa.team_id = wbxt.team_id),
rslt AS (SELECT act_id, cash_value
FROM account_summary am
WHERE attr2 IN (SELECT FILTER_TOKEN FROM replist))
SELECT /* use_hash(rslt) */
SUM (cash_value)
FROM rslt
WHERE EXISTS (SELECT '1'
FROM actlist
WHERE account_id = act_id);
PLAN_TABLE_OUTPUT
Plan hash value: 900710482
--------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 131 | 7906 (7)| 00:01:35 |
| 1 | SORT AGGREGATE | | 1 | 131 | | |
| 2 | NESTED LOOPS | | | | | |
| 3 | NESTED LOOPS | | 104 | 13624 | 105 (1)| 00:00:02 |
| 4 | VIEW | VW_NSO_1 | 12 | 1224 | 6 (0)| 00:00:01 |
| 5 | SORT UNIQUE | | 12 | 504 | | |
| 6 | NESTED LOOPS | | 12 | 504 | 6 (0)| 00:00:01 |
| 7 | NESTED LOOPS | | 1 | 23 | 4 (0)| 00:00:01 |
|* 8 | TABLE ACCESS BY INDEX ROWID| WEB_DATA_SETTING | 1 | 12 | 2 (0)| 00:00:01 |
|* 9 | INDEX RANGE SCAN | WEB_DATASETNG_I_BROKER_ID | 1 | | 1 (0)| 00:00:01 |
|* 10 | INDEX RANGE SCAN | WEB_INST_QRY_N_DSID | 1 | 11 | 2 (0)| 00:00:01 |
|* 11 | INDEX RANGE SCAN | WEBDATASETDTL_PK_TEAM | 12 | 228 | 2 (0)| 00:00:01 |
|* 12 | INDEX RANGE SCAN | ACCOUNT_SUMM_I_ATT_MAR_ACT_ID | 9 | | 2 (0)| 00:00:01 |
|* 13 | HASH JOIN | | 1 | 31 | 8 (13)| 00:00:01 |
|* 14 | INDEX RANGE SCAN | WTT_PK | 3 | 57 | 4 (0)| 00:00:01 |
|* 15 | INDEX RANGE SCAN | WBXT_PK_BROKER_TEAM_ID1 | 13 | 156 | 3 (0)| 00:00:01 |
| 16 | TABLE ACCESS BY INDEX ROWID | ACCOUNT_SUMMARY | 9 | 261 | 11 (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
8 - filter("DEFAULT_YN"='Y')
9 - access("BROKER_ID"=48270)
10 - access("INST_QUERY_ID"=1385776)
11 - access("WDSD"."DATA_SETTING_ID"=NVL("Y"."DATA_SETTING_ID","DATA_SETTING_ID"))
12 - access("ATTR2"="FILTER_TOKEN")
filter( EXISTS (SELECT /*+ USE_HASH ("WBXT") USE_HASH ("BO_TEAM_X_ACCOUNT") */ 0 FROM
"WEB_OWNER"."WEB_BROKER_X_TEAM" "WBXT",BO_OWNER_INST_10274_1."BO_TEAM_X_ACCOUNT" "BO_TEAM_X_ACCOUNT" WHERE
"ACCOUNT_ID"=:B1 AND "WBXT"."BROKER_ID"=48270 AND "TEAM_ID"="WBXT"."TEAM_ID"))
13 - access("TEAM_ID"="WBXT"."TEAM_ID")
14 - access("ACCOUNT_ID"=:B1)
15 - access("WBXT"."BROKER_ID"=48270)
The tables in the query has the following cardinality
web_team_x_account -- 60Million
web_broker_x_team -- 1Million
account_summary -- 9Million
and replist WITH clause returns 25 rows and that is against metadata tables and that part of the query is pretty quick
The whole query is taking more than minute if actlist WITH clause returns more than 1million rows. I mean for all the brokers where
there are more accounts the query is really slow.
Can someone please help?
[update by JW: I've added code tags to make it readable, Naveen; please do this yourself in future, BlackSwan has given you the link with instructions]
[Updated on: Fri, 09 September 2011 13:46] by Moderator Report message to a moderator
|
|
|
|
Re: Tuning help needed [message #522456 is a reply to message #522450] |
Fri, 09 September 2011 14:10 |
|
naveenreddy
Messages: 10 Registered: August 2011
|
Junior Member |
|
|
WITH replist AS
(SELECT
DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT
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 = 48270
AND DEFAULT_YN = 'Y'
) X
WHERE inst_query_id = 1385776
) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id
)
rep_set
),
actlist AS
(SELECT
account_id
FROM web_team_x_account wtxa,
web_broker_x_team wbxt
WHERE wbxt.broker_id = 48270
AND wtxa.team_id = wbxt.team_id
),
rslt AS
(SELECT
act_id,
cash_value
FROM account_summary am
WHERE attr2 IN (SELECT FILTER_TOKEN FROM replist)
)
SELECT
SUM (cash_value)
FROM rslt
WHERE EXISTS (SELECT '1'
FROM actlist
HERE account_id = act_id
);
SQL> @brkr.sql
SUM(CASH_VALUE)
---------------
1307269944
Elapsed: 00:07:22.99
SQL>
Attached is the file which has the DDL's for the tables. Please let me know if I have missed anything
-
Attachment: orafaq.txt
(Size: 12.84KB, Downloaded 1808 times)
|
|
|
|
|
|
|
Re: Tuning help needed [message #522761 is a reply to message #522468] |
Tue, 13 September 2011 09:20 |
|
naveenreddy
Messages: 10 Registered: August 2011
|
Junior Member |
|
|
Please find the requested output. Let me know if I have missed anything
SQL> set linesize 1000
SQL> set pagesize 1000
SQL> set timing on
SQL> set trimout on
SQL> set trimspool on
SQL> alter session set statistics_level=all;
Session altered.
Elapsed: 00:00:00.01
SQL> @brkr.sql
SUM(CASH_VALUE)
---------------
1307269944
Elapsed: 00:17:23.01
SQL> select plan_table_output from table ( sys.dbms_xplan.display_cursor( '','','ADVANCED ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------------------------------------------------------------------------- ----------------------------------
SQL_ID gak3hj6rtuug3, child number 0
-------------------------------------
WITH replist AS (SELECT DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT
wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = :"SYS_B_0"
AND DEFAULT_YN = :"SYS_B_1") X WHERE
inst_query_id = :"SYS_B_2") wiq WHERE
wiq.data_setting_id = wdsd.data_setting_id)
Plan hash value: 733012279
------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 4003 (100)| | 1 |00:16:58.53 | 815K| 120K| | | |
| 1 | SORT AGGREGATE | | 1 | 1 | 131 | | | 1 |00:16:58.53 | 815K| 120K| | | |
| 2 | NESTED LOOPS | | 1 | | | | | 135K|00:16:58.36 | 815K| 120K| | | |
| 3 | NESTED LOOPS | | 1 | 52 | 6812 | 125 (1)| 00:00:02 | 135K|00:06:41.97 | 680K| 48278 | | | |
| 4 | VIEW | VW_NSO_1 | 1 | 12 | 1224 | 6 (0)| 00:00:01 | 25 |00:00:00.01 | 9 | 3 | | | |
| 5 | SORT UNIQUE | | 1 | 12 | 504 | | | 25 |00:00:00.01 | 9 | 3 | 2048 | 2048 | 2048 (0)|
| 6 | NESTED LOOPS | | 1 | 12 | 504 | 6 (0)| 00:00:01 | 25 |00:00:00.01 | 9 | 3 | | | |
| 7 | MERGE JOIN CARTESIAN | | 1 | 1 | 23 | 4 (0)| 00:00:01 | 1 |00:00:00.01 | 6 | 2 | | | |
|* 8 | TABLE ACCESS BY INDEX ROWID| WEB_DATA_SETTING | 1 | 1 | 12 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | | | |
|* 9 | INDEX RANGE SCAN | WEB_DATASETNG_I_BROKER_ID | 1 | 1 | | 1 (0)| 00:00:01 | 1 |00:00:00.01 | 2 | 1 | | | |
| 10 | BUFFER SORT | | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | 73728 | 73728 | |
|* 11 | INDEX RANGE SCAN | WEB_INST_QRY_N_DSID | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | | | |
|* 12 | INDEX RANGE SCAN | WEBDATASETDTL_PK_TEAM | 1 | 12 | 228 | 2 (0)| 00:00:01 | 25 |00:00:00.01 | 3 | 1 | | | |
|* 13 | INDEX RANGE SCAN | ACCOUNT_SUMM_I_ATT_MAR_ACT_ID | 25 | 9 | | 3 (0)| 00:00:01 | 135K|00:06:41.86 | 680K| 48275 | | | |
|* 14 | HASH JOIN | | 135K| 1 | 31 | 8 (13)| 00:00:01 | 135K|00:06:38.66 | 679K| 47470 | 1236K| 1236K| 603K (0)|
|* 15 | INDEX RANGE SCAN | WTT_PK | 135K| 3 | 57 | 4 (0)| 00:00:01 | 406K|00:06:11.59 | 543K| 47470 | | | |
|* 16 | INDEX RANGE SCAN | WBXT_PK_BROKER_TEAM_ID1 | 135K| 13 | 156 | 3 (0)| 00:00:01 | 135K|00:00:00.54 | 135K| 0 | | | |
| 17 | TABLE ACCESS BY INDEX ROWID | ACCOUNT_SUMMARY | 135K| 4 | 116 | 13 (0)| 00:00:01 | 135K|00:10:16.23 | 135K| 71802 | | | |
------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$20FF7734
4 - SEL$976A52FC / VW_NSO_1@SEL$20FF7734
5 - SEL$976A52FC
8 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
9 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
11 - SEL$976A52FC / Y@SEL$3
12 - SEL$976A52FC / WDSD@SEL$2
13 - SEL$20FF7734 / AM@SEL$7
14 - SEL$FC1F63E8
15 - SEL$FC1F63E8 / BO_TEAM_X_ACCOUNT@SEL$6
16 - SEL$FC1F63E8 / WBXT@SEL$5
17 - SEL$20FF7734 / AM@SEL$7
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
DB_VERSION('11.1.0.7')
OPT_PARAM('_gby_hash_aggregation_enabled' 'false')
ALL_ROWS
OUTLINE_LEAF(@"SEL$FC1F63E8")
MERGE(@"SEL$ABDE6DFF")
OUTLINE_LEAF(@"SEL$976A52FC")
OUTLINE_LEAF(@"SEL$20FF7734")
UNNEST(@"SEL$87FA6C3C")
OUTLINE(@"SEL$10")
OUTLINE(@"SEL$ABDE6DFF")
MERGE(@"SEL$6")
OUTLINE(@"SEL$87FA6C3C")
MERGE(@"SEL$88122447")
OUTLINE(@"SEL$E2C0F2F4")
MERGE(@"SEL$7")
OUTLINE(@"SEL$5")
OUTLINE(@"SEL$6")
OUTLINE(@"SEL$8")
OUTLINE(@"SEL$88122447")
MERGE(@"SEL$641071AC")
OUTLINE(@"SEL$9")
OUTLINE(@"SEL$7")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$641071AC")
MERGE(@"SEL$07BDC5B4")
OUTLINE(@"SEL$2")
OUTLINE(@"SEL$07BDC5B4")
MERGE(@"SEL$4")
OUTLINE(@"SEL$3")
OUTLINE(@"SEL$4")
NO_ACCESS(@"SEL$20FF7734" "VW_NSO_1"@"SEL$20FF7734")
INDEX(@"SEL$20FF7734" "AM"@"SEL$7" ("ACCOUNT_SUMMARY"."ATTR2" "ACCOUNT_SUMMARY"."MARKET_VALUE" "ACCOUNT_SUMMARY"."ACT_ID"))
LEADING(@"SEL$20FF7734" "VW_NSO_1"@"SEL$20FF7734" "AM"@"SEL$7")
USE_NL(@"SEL$20FF7734" "AM"@"SEL$7")
NLJ_BATCHING(@"SEL$20FF7734" "AM"@"SEL$7")
PUSH_SUBQ(@"SEL$FC1F63E8")
INDEX_RS_ASC(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" ("WEB_DATA_SETTING"."BROKER_ID"))
INDEX(@"SEL$976A52FC" "Y"@"SEL$3" ("WEB_INSTANTIABLE_QUERY"."INST_QUERY_ID" "WEB_INSTANTIABLE_QUERY"."DATA_SETTING_ID"))
INDEX(@"SEL$976A52FC" "WDSD"@"SEL$2" ("WEB_DATA_SETTING_DETAIL"."DATA_SETTING_ID" "WEB_DATA_SETTING_DETAIL"."FILTER_TOKEN" "WEB_DATA_SETTING_DETAIL"."RLS_ID"))
LEADING(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" "Y"@"SEL$3" "WDSD"@"SEL$2")
USE_MERGE_CARTESIAN(@"SEL$976A52FC" "Y"@"SEL$3")
USE_NL(@"SEL$976A52FC" "WDSD"@"SEL$2")
INDEX(@"SEL$FC1F63E8" "BO_TEAM_X_ACCOUNT"@"SEL$6" ("BO_TEAM_X_ACCOUNT"."ACCOUNT_ID" "BO_TEAM_X_ACCOUNT"."TEAM_ID"))
INDEX(@"SEL$FC1F63E8" "WBXT"@"SEL$5" ("WEB_BROKER_X_TEAM"."BROKER_ID" "WEB_BROKER_X_TEAM"."TEAM_ID"))
LEADING(@"SEL$FC1F63E8" "BO_TEAM_X_ACCOUNT"@"SEL$6" "WBXT"@"SEL$5")
USE_HASH(@"SEL$FC1F63E8" "WBXT"@"SEL$5")
PX_JOIN_FILTER(@"SEL$FC1F63E8" "WBXT"@"SEL$5")
END_OUTLINE_DATA
*/
Peeked Binds (identified by position):
--------------------------------------
1 - :SYS_B_0 (NUMBER): 48270
2 - :SYS_B_1 (VARCHAR2(30), CSID=873): 'Y'
3 - :SYS_B_2 (NUMBER): 1385776
Predicate Information (identified by operation id):
---------------------------------------------------
8 - filter("DEFAULT_YN"=:SYS_B_1)
9 - access("BROKER_ID"=:SYS_B_0)
11 - access("INST_QUERY_ID"=:SYS_B_2)
12 - access("WDSD"."DATA_SETTING_ID"=NVL("Y"."DATA_SETTING_ID","DATA_SETTING_ID"))
13 - access("ATTR2"="FILTER_TOKEN")
filter( IS NOT NULL)
14 - access("TEAM_ID"="WBXT"."TEAM_ID")
15 - access("ACCOUNT_ID"=:B1)
16 - access("WBXT"."BROKER_ID"=:SYS_B_3)
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - (#keys=0) SUM("CASH_VALUE")[22]
2 - "CASH_VALUE"[NUMBER,22]
3 - "SYS_ALIAS_1".ROWID[ROWID,10]
4 - "FILTER_TOKEN"[VARCHAR2,200]
5 - (#keys=1) "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
6 - "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
7 - "DATA_SETTING_ID"[NUMBER,22], "Y"."DATA_SETTING_ID"[NUMBER,22]
8 - "DATA_SETTING_ID"[NUMBER,22]
9 - "WEB_DATA_SETTING".ROWID[ROWID,10]
10 - (#keys=0) "Y"."DATA_SETTING_ID"[NUMBER,22]
11 - "Y"."DATA_SETTING_ID"[NUMBER,22]
12 - "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
13 - "SYS_ALIAS_1".ROWID[ROWID,10]
14 - (#keys=1)
15 - "TEAM_ID"[VARCHAR2,200]
16 - "WBXT"."TEAM_ID"[VARCHAR2,200]
17 - "CASH_VALUE"[NUMBER,22]
157 rows selected.
Elapsed: 00:00:00.31
SQL>
|
|
|
Re: Tuning help needed [message #522762 is a reply to message #522458] |
Tue, 13 September 2011 09:29 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
naveenreddy wrote on Tue, 13 September 2011 15:20Please find the requested output. Let me know if I have missed anything
What did John say?
John Watson wrote on Fri, 09 September 2011 20:21What you've missed is using [code] tags. There are some very helpful people here, but they won't talk to you unless you format your code with the code tag described here:
http://www.orafaq.com/forum/t/174502/164379/
I added them to your first post, can you see how much easier it is to read now?
|
|
|
|
|
Re: Tuning help needed [message #522930 is a reply to message #522927] |
Wed, 14 September 2011 08:45 |
cookiemonster
Messages: 13962 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
How many times do we have to tell you to use code tags? This would be number 3.
A lot of people here can't/won't download files. So post the output in line, formatted, in code tags.
|
|
|
Re: Tuning help needed [message #522933 is a reply to message #522930] |
Wed, 14 September 2011 09:04 |
|
naveenreddy
Messages: 10 Registered: August 2011
|
Junior Member |
|
|
SQL>
SQL> set linesize 1000
SQL> set pagesize 1000
SQL> set timing on
SQL> set trimout on
SQL> set trimspool on
SQL> alter session set statistics_level=all;
Session altered.
Elapsed: 00:00:00.01
SQL> @brkr.sql
SUM(CASH_VALUE)
---------------
1307269944
Elapsed: 00:17:23.01
SQL> select plan_table_output from table ( sys.dbms_xplan.display_cursor( '','','ADVANCED ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID gak3hj6rtuug3, child number 0
-------------------------------------
WITH replist AS
(SELECT DISTINCT rep_set.FILTER_TOKEN
FROM
(SELECT DISTINCT wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = :"SYS_B_0"
AND DEFAULT_YN = :"SYS_B_1"
) X
WHERE inst_query_id = :"SYS_B_2"
) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id)
Plan hash value: 733012279
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 4003 (100)| | 1 |00:16:58.53 | 815K| 120K| | | |
| 1 | SORT AGGREGATE | | 1 | 1 | 131 | | | 1 |00:16:58.53 | 815K| 120K| | | |
| 2 | NESTED LOOPS | | 1 | | | | | 135K|00:16:58.36 | 815K| 120K| | | |
| 3 | NESTED LOOPS | | 1 | 52 | 6812 | 125 (1)| 00:00:02 | 135K|00:06:41.97 | 680K| 48278 | | | |
| 4 | VIEW | VW_NSO_1 | 1 | 12 | 1224 | 6 (0)| 00:00:01 | 25 |00:00:00.01 | 9 | 3 | | | |
| 5 | SORT UNIQUE | | 1 | 12 | 504 | | | 25 |00:00:00.01 | 9 | 3 | 2048 | 2048 | 2048 (0)|
| 6 | NESTED LOOPS | | 1 | 12 | 504 | 6 (0)| 00:00:01 | 25 |00:00:00.01 | 9 | 3 | | | |
| 7 | MERGE JOIN CARTESIAN | | 1 | 1 | 23 | 4 (0)| 00:00:01 | 1 |00:00:00.01 | 6 | 2 | | | |
|* 8 | TABLE ACCESS BY INDEX ROWID| WEB_DATA_SETTING | 1 | 1 | 12 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | | | |
|* 9 | INDEX RANGE SCAN | WEB_DATASETNG_I_BROKER_ID | 1 | 1 | | 1 (0)| 00:00:01 | 1 |00:00:00.01 | 2 | 1 | | | |
| 10 | BUFFER SORT | | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | 73728 | 73728 | |
|* 11 | INDEX RANGE SCAN | WEB_INST_QRY_N_DSID | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.01 | 3 | 1 | | | |
|* 12 | INDEX RANGE SCAN | WEBDATASETDTL_PK_TEAM | 1 | 12 | 228 | 2 (0)| 00:00:01 | 25 |00:00:00.01 | 3 | 1 | | | |
|* 13 | INDEX RANGE SCAN | ACCOUNT_SUMM_I_ATT_MAR_ACT_ID | 25 | 9 | | 3 (0)| 00:00:01 | 135K|00:06:41.86 | 680K| 48275 | | | |
|* 14 | HASH JOIN | | 135K| 1 | 31 | 8 (13)| 00:00:01 | 135K|00:06:38.66 | 679K| 47470 | 1236K| 1236K| 603K (0)|
|* 15 | INDEX RANGE SCAN | WTT_PK | 135K| 3 | 57 | 4 (0)| 00:00:01 | 406K|00:06:11.59 | 543K| 47470 | | | |
|* 16 | INDEX RANGE SCAN | WBXT_PK_BROKER_TEAM_ID1 | 135K| 13 | 156 | 3 (0)| 00:00:01 | 135K|00:00:00.54 | 135K| 0 | | | |
| 17 | TABLE ACCESS BY INDEX ROWID | ACCOUNT_SUMMARY | 135K| 4 | 116 | 13 (0)| 00:00:01 | 135K|00:10:16.23 | 135K| 71802 | | | |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$20FF7734
4 - SEL$976A52FC / VW_NSO_1@SEL$20FF7734
5 - SEL$976A52FC
8 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
9 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
11 - SEL$976A52FC / Y@SEL$3
12 - SEL$976A52FC / WDSD@SEL$2
13 - SEL$20FF7734 / AM@SEL$7
14 - SEL$FC1F63E8
15 - SEL$FC1F63E8 / BO_TEAM_X_ACCOUNT@SEL$6
16 - SEL$FC1F63E8 / WBXT@SEL$5
17 - SEL$20FF7734 / AM@SEL$7
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
DB_VERSION('11.1.0.7')
OPT_PARAM('_gby_hash_aggregation_enabled' 'false')
ALL_ROWS
OUTLINE_LEAF(@"SEL$FC1F63E8")
MERGE(@"SEL$ABDE6DFF")
OUTLINE_LEAF(@"SEL$976A52FC")
OUTLINE_LEAF(@"SEL$20FF7734")
UNNEST(@"SEL$87FA6C3C")
OUTLINE(@"SEL$10")
OUTLINE(@"SEL$ABDE6DFF")
MERGE(@"SEL$6")
OUTLINE(@"SEL$87FA6C3C")
MERGE(@"SEL$88122447")
OUTLINE(@"SEL$E2C0F2F4")
MERGE(@"SEL$7")
OUTLINE(@"SEL$5")
OUTLINE(@"SEL$6")
OUTLINE(@"SEL$8")
OUTLINE(@"SEL$88122447")
MERGE(@"SEL$641071AC")
OUTLINE(@"SEL$9")
OUTLINE(@"SEL$7")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$641071AC")
MERGE(@"SEL$07BDC5B4")
OUTLINE(@"SEL$2")
OUTLINE(@"SEL$07BDC5B4")
MERGE(@"SEL$4")
OUTLINE(@"SEL$3")
OUTLINE(@"SEL$4")
NO_ACCESS(@"SEL$20FF7734" "VW_NSO_1"@"SEL$20FF7734")
INDEX(@"SEL$20FF7734" "AM"@"SEL$7" ("ACCOUNT_SUMMARY"."ATTR2" "ACCOUNT_SUMMARY"."MARKET_VALUE" "ACCOUNT_SUMMARY"."ACT_ID"))
LEADING(@"SEL$20FF7734" "VW_NSO_1"@"SEL$20FF7734" "AM"@"SEL$7")
USE_NL(@"SEL$20FF7734" "AM"@"SEL$7")
NLJ_BATCHING(@"SEL$20FF7734" "AM"@"SEL$7")
PUSH_SUBQ(@"SEL$FC1F63E8")
INDEX_RS_ASC(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" ("WEB_DATA_SETTING"."BROKER_ID"))
INDEX(@"SEL$976A52FC" "Y"@"SEL$3" ("WEB_INSTANTIABLE_QUERY"."INST_QUERY_ID" "WEB_INSTANTIABLE_QUERY"."DATA_SETTING_ID"))
INDEX(@"SEL$976A52FC" "WDSD"@"SEL$2" ("WEB_DATA_SETTING_DETAIL"."DATA_SETTING_ID" "WEB_DATA_SETTING_DETAIL"."FILTER_TOKEN" "WEB_DATA_SETTING_DETAIL"."RLS_ID"))
LEADING(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" "Y"@"SEL$3" "WDSD"@"SEL$2")
USE_MERGE_CARTESIAN(@"SEL$976A52FC" "Y"@"SEL$3")
USE_NL(@"SEL$976A52FC" "WDSD"@"SEL$2")
INDEX(@"SEL$FC1F63E8" "BO_TEAM_X_ACCOUNT"@"SEL$6" ("BO_TEAM_X_ACCOUNT"."ACCOUNT_ID" "BO_TEAM_X_ACCOUNT"."TEAM_ID"))
INDEX(@"SEL$FC1F63E8" "WBXT"@"SEL$5" ("WEB_BROKER_X_TEAM"."BROKER_ID" "WEB_BROKER_X_TEAM"."TEAM_ID"))
LEADING(@"SEL$FC1F63E8" "BO_TEAM_X_ACCOUNT"@"SEL$6" "WBXT"@"SEL$5")
USE_HASH(@"SEL$FC1F63E8" "WBXT"@"SEL$5")
PX_JOIN_FILTER(@"SEL$FC1F63E8" "WBXT"@"SEL$5")
END_OUTLINE_DATA
*/
Peeked Binds (identified by position):
--------------------------------------
1 - :SYS_B_0 (NUMBER): 48270
2 - :SYS_B_1 (VARCHAR2(30), CSID=873): 'Y'
3 - :SYS_B_2 (NUMBER): 1385776
Predicate Information (identified by operation id):
---------------------------------------------------
8 - filter("DEFAULT_YN"=:SYS_B_1)
9 - access("BROKER_ID"=:SYS_B_0)
11 - access("INST_QUERY_ID"=:SYS_B_2)
12 - access("WDSD"."DATA_SETTING_ID"=NVL("Y"."DATA_SETTING_ID","DATA_SETTING_ID"))
13 - access("ATTR2"="FILTER_TOKEN")
filter( IS NOT NULL)
14 - access("TEAM_ID"="WBXT"."TEAM_ID")
15 - access("ACCOUNT_ID"=:B1)
16 - access("WBXT"."BROKER_ID"=:SYS_B_3)
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - (#keys=0) SUM("CASH_VALUE")[22]
2 - "CASH_VALUE"[NUMBER,22]
3 - "SYS_ALIAS_1".ROWID[ROWID,10]
4 - "FILTER_TOKEN"[VARCHAR2,200]
5 - (#keys=1) "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
6 - "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
7 - "DATA_SETTING_ID"[NUMBER,22], "Y"."DATA_SETTING_ID"[NUMBER,22]
8 - "DATA_SETTING_ID"[NUMBER,22]
9 - "WEB_DATA_SETTING".ROWID[ROWID,10]
10 - (#keys=0) "Y"."DATA_SETTING_ID"[NUMBER,22]
11 - "Y"."DATA_SETTING_ID"[NUMBER,22]
12 - "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
13 - "SYS_ALIAS_1".ROWID[ROWID,10]
14 - (#keys=1)
15 - "TEAM_ID"[VARCHAR2,200]
16 - "WBXT"."TEAM_ID"[VARCHAR2,200]
17 - "CASH_VALUE"[NUMBER,22]
157 rows selected.
Elapsed: 00:00:00.31
SQL>
|
|
|
Re: Tuning help needed [message #522940 is a reply to message #522933] |
Wed, 14 September 2011 11:12 |
|
LNossov
Messages: 318 Registered: July 2011 Location: Germany
|
Senior Member |
|
|
So, you have two critical points:
1. rslt
Even though replist retuns only 25 rows, rslt retuns 135K rows.
You cannot reduce this number, so you cannot expect to get a result VERY fast.
2. the hash join will be done 135K times (for each row of rslt) and costs 6:38 min.
In my opinion you have a chance to improve your sql, if actlist itself retuns not too many rows.
I hope, the column team_id of web_team_x_account is indexed. It is important, because this table is very big.
If it is really so, you can try the following sql:
WITH replist
AS (SELECT DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT
wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = 48270
AND DEFAULT_YN = 'Y') X
WHERE inst_query_id = 1385776) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id)
rep_set),
actlist
AS (SELECT /*+ materialize */
account_id
FROM web_team_x_account wtxa, web_broker_x_team wbxt
WHERE wbxt.broker_id = 48270 AND wtxa.team_id = wbxt.team_id),
rslt AS (SELECT act_id, cash_value
FROM account_summary am
WHERE attr2 IN (SELECT FILTER_TOKEN FROM replist))
SELECT
SUM (cash_value)
FROM rslt
WHERE act_id in (SELECT account_id FROM actlist);
I think, you don't need the materialize hint really. So you can try also without this hint.
If my assumption is not true (i.e. actlist retuns very many rows), then I don't see any possibility to improve your sql.
In this case you could make it faster by using of PQ for ex.
|
|
|
|
|
|
Re: Tuning help needed [message #523096 is a reply to message #522956] |
Thu, 15 September 2011 09:38 |
|
naveenreddy
Messages: 10 Registered: August 2011
|
Junior Member |
|
|
Please find the output from the query you suggested.
SQL> set linesize 1000
SQL> set pagesize 1000
SQL> set timing on
SQL> set trimout on
SQL> set trimspool on
SQL> alter session set statistics_level=all;
Session altered.
Elapsed: 00:00:00.00
SQL> @brkr1.sql
SUM(CASH_VALUE)
---------------
1307269944
Elapsed: 00:04:12.22
SQL> select plan_table_output from table ( sys.dbms_xplan.display_cursor( '','','ADVANCED ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 69c09smxytbww, child number 0
-------------------------------------
WITH replist AS
(SELECT DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = :"SYS_B_0"
AND DEFAULT_YN = :"SYS_B_1"
) X
WHERE inst_query_id = :"SYS_B_2"
) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id
)
Plan hash value: 606275876
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time | A-Rows | A-Time | Buffers | Reads | Writes | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | | 1576 (100)| | 1 |00:03:09.07 | 115K| 114K| 1164 | | | |
| 1 | TEMP TABLE TRANSFORMATION | | 1 | | | | | 1 |00:03:09.07 | 115K| 114K| 1164 | | | |
| 2 | LOAD AS SELECT | | 1 | | | | | 1 |00:00:08.28 | 3159 | 1993 | 1164 | 525K| 525K| 525K (0)|
| 3 | NESTED LOOPS | | 1 | 18107 | 548K| 128 (0)| 00:00:02 | 525K|00:00:07.57 | 1991 | 1991 | 0 | | | |
|* 4 | INDEX RANGE SCAN | WBXT_PK_BROKER_TEAM_ID1 | 1 | 25 | 300 | 3 (0)| 00:00:01 | 1 |00:00:00.17 | 3 | 3 | 0 | | | |
|* 5 | INDEX RANGE SCAN | WTT_U_TEAM_ACCOUNT | 1 | 720 | 13680 | 5 (0)| 00:00:01 | 525K|00:00:07.40 | 1988 | 1988 | 0 | | | |
| 6 | SORT AGGREGATE | | 1 | 1 | 233 | | | 1 |00:03:00.78 | 112K| 112K| 0 | | | |
|* 7 | HASH JOIN SEMI | | 1 | 2 | 466 | 1448 (1)| 00:00:18 | 135K|00:03:00.74 | 112K| 112K| 0 | 11M| 2193K| 13M (0)|
| 8 | NESTED LOOPS | | 1 | | | | | 135K|00:03:55.93 | 111K| 111K| 0 | | | |
| 9 | NESTED LOOPS | | 1 | 1016 | 129K| 1424 (1)| 00:00:18 | 135K|00:00:01.28 | 533 | 507 | 0 | | | |
| 10 | VIEW | VW_NSO_2 | 1 | 12 | 1224 | 6 (0)| 00:00:01 | 25 |00:00:00.11 | 9 | 9 | 0 | | | |
| 11 | SORT UNIQUE | | 1 | 12 | 504 | | | 25 |00:00:00.11 | 9 | 9 | 0 | 2048 | 2048 | 2048 (0)|
| 12 | NESTED LOOPS | | 1 | 12 | 504 | 6 (0)| 00:00:01 | 25 |00:00:00.11 | 9 | 9 | 0 | | | |
| 13 | MERGE JOIN CARTESIAN | | 1 | 1 | 23 | 4 (0)| 00:00:01 | 1 |00:00:00.06 | 6 | 6 | 0 | | | |
|* 14 | TABLE ACCESS BY INDEX ROWID| WEB_DATA_SETTING | 1 | 1 | 12 | 2 (0)| 00:00:01 | 1 |00:00:00.02 | 3 | 3 | 0 | | | |
|* 15 | INDEX RANGE SCAN | WEB_DATASETNG_I_BROKER_ID | 1 | 1 | | 1 (0)| 00:00:01 | 1 |00:00:00.02 | 2 | 2 | 0 | | | |
| 16 | BUFFER SORT | | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.05 | 3 | 3 | 0 | 73728 | 73728 | |
|* 17 | INDEX RANGE SCAN | WEB_INST_QRY_N_DSID | 1 | 1 | 11 | 2 (0)| 00:00:01 | 1 |00:00:00.05 | 3 | 3 | 0 | | | |
|* 18 | INDEX RANGE SCAN | WEBDATASETDTL_PK_TEAM | 1 | 12 | 228 | 2 (0)| 00:00:01 | 25 |00:00:00.04 | 3 | 3 | 0 | | | |
|* 19 | INDEX RANGE SCAN | ACCOUNT_SUMMARY_I_ATTR2 | 25 | 173 | | 2 (0)| 00:00:01 | 135K|00:00:01.12 | 524 | 498 | 0 | | | |
| 20 | TABLE ACCESS BY INDEX ROWID | ACCOUNT_SUMMARY | 135K| 85 | 2465 | 172 (0)| 00:00:03 | 135K|00:03:54.53 | 110K| 110K| 0 | | | |
| 21 | VIEW | VW_NSO_1 | 1 | 18107 | 1803K| 23 (0)| 00:00:01 | 525K|00:00:00.58 | 1169 | 1164 | 0 | | | |
| 22 | VIEW | | 1 | 18107 | 1803K| 23 (0)| 00:00:01 | 525K|00:00:00.58 | 1169 | 1164 | 0 | | | |
| 23 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6AF0_E165D39D | 1 | 18107 | 194K| 23 (0)| 00:00:01 | 525K|00:00:00.58 | 1169 | 1164 | 0 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
1 - SEL$B41FED86
2 - SEL$ABDE6DFF
4 - SEL$ABDE6DFF / WBXT@SEL$5
5 - SEL$ABDE6DFF / BO_TEAM_X_ACCOUNT@SEL$6
10 - SEL$976A52FC / VW_NSO_2@SEL$B41FED86
11 - SEL$976A52FC
14 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
15 - SEL$976A52FC / WEB_DATA_SETTING@SEL$4
17 - SEL$976A52FC / Y@SEL$3
18 - SEL$976A52FC / WDSD@SEL$2
19 - SEL$B41FED86 / AM@SEL$7
20 - SEL$B41FED86 / AM@SEL$7
21 - SEL$0DDF58A2 / VW_NSO_1@SEL$B41FED86
22 - SEL$513E976F / ACTLIST@SEL$10
23 - SEL$513E976F / T1@SEL$513E976F
Outline Data
-------------
/*+
BEGIN_OUTLINE_DATA
IGNORE_OPTIM_EMBEDDED_HINTS
OPTIMIZER_FEATURES_ENABLE('11.1.0.7')
DB_VERSION('11.1.0.7')
OPT_PARAM('_gby_hash_aggregation_enabled' 'false')
ALL_ROWS
OUTLINE_LEAF(@"SEL$ABDE6DFF")
MERGE(@"SEL$6")
OUTLINE_LEAF(@"SEL$976A52FC")
OUTLINE_LEAF(@"SEL$513E976F")
OUTLINE_LEAF(@"SEL$0DDF58A2")
OUTLINE_LEAF(@"SEL$B41FED86")
UNNEST(@"SEL$10")
UNNEST(@"SEL$87FA6C3C")
OUTLINE(@"SEL$5")
OUTLINE(@"SEL$6")
OUTLINE(@"SEL$87FA6C3C")
MERGE(@"SEL$88122447")
OUTLINE(@"SEL$ABDE6DFF")
MERGE(@"SEL$6")
OUTLINE(@"SEL$10")
OUTLINE(@"SEL$E2C0F2F4")
MERGE(@"SEL$7")
OUTLINE(@"SEL$8")
OUTLINE(@"SEL$88122447")
MERGE(@"SEL$641071AC")
OUTLINE(@"SEL$9")
OUTLINE(@"SEL$7")
OUTLINE(@"SEL$1")
OUTLINE(@"SEL$641071AC")
MERGE(@"SEL$07BDC5B4")
OUTLINE(@"SEL$2")
OUTLINE(@"SEL$07BDC5B4")
MERGE(@"SEL$4")
OUTLINE(@"SEL$3")
OUTLINE(@"SEL$4")
NO_ACCESS(@"SEL$B41FED86" "VW_NSO_2"@"SEL$B41FED86")
INDEX(@"SEL$B41FED86" "AM"@"SEL$7" ("ACCOUNT_SUMMARY"."ATTR2"))
NO_ACCESS(@"SEL$B41FED86" "VW_NSO_1"@"SEL$B41FED86")
LEADING(@"SEL$B41FED86" "VW_NSO_2"@"SEL$B41FED86" "AM"@"SEL$7" "VW_NSO_1"@"SEL$B41FED86")
USE_NL(@"SEL$B41FED86" "AM"@"SEL$7")
NLJ_BATCHING(@"SEL$B41FED86" "AM"@"SEL$7")
USE_HASH(@"SEL$B41FED86" "VW_NSO_1"@"SEL$B41FED86")
INDEX_RS_ASC(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" ("WEB_DATA_SETTING"."BROKER_ID"))
INDEX(@"SEL$976A52FC" "Y"@"SEL$3" ("WEB_INSTANTIABLE_QUERY"."INST_QUERY_ID" "WEB_INSTANTIABLE_QUERY"."DATA_SETTING_ID"))
INDEX(@"SEL$976A52FC" "WDSD"@"SEL$2" ("WEB_DATA_SETTING_DETAIL"."DATA_SETTING_ID" "WEB_DATA_SETTING_DETAIL"."FILTER_TOKEN" "WEB_DATA_SETTING_DETAIL"."RLS_ID"))
LEADING(@"SEL$976A52FC" "WEB_DATA_SETTING"@"SEL$4" "Y"@"SEL$3" "WDSD"@"SEL$2")
USE_MERGE_CARTESIAN(@"SEL$976A52FC" "Y"@"SEL$3")
USE_NL(@"SEL$976A52FC" "WDSD"@"SEL$2")
NO_ACCESS(@"SEL$0DDF58A2" "ACTLIST"@"SEL$10")
FULL(@"SEL$513E976F" "T1"@"SEL$513E976F")
INDEX(@"SEL$ABDE6DFF" "WBXT"@"SEL$5" ("WEB_BROKER_X_TEAM"."BROKER_ID" "WEB_BROKER_X_TEAM"."TEAM_ID"))
INDEX(@"SEL$ABDE6DFF" "BO_TEAM_X_ACCOUNT"@"SEL$6" ("BO_TEAM_X_ACCOUNT"."TEAM_ID" "BO_TEAM_X_ACCOUNT"."ACCOUNT_ID"))
LEADING(@"SEL$ABDE6DFF" "WBXT"@"SEL$5" "BO_TEAM_X_ACCOUNT"@"SEL$6")
USE_NL(@"SEL$ABDE6DFF" "BO_TEAM_X_ACCOUNT"@"SEL$6")
END_OUTLINE_DATA
*/
Peeked Binds (identified by position):
--------------------------------------
1 - :SYS_B_0 (NUMBER): 48270
2 - :SYS_B_1 (VARCHAR2(30), CSID=873): 'Y'
3 - :SYS_B_2 (NUMBER): 1385776
Predicate Information (identified by operation id):
---------------------------------------------------
4 - access("WBXT"."BROKER_ID"=:SYS_B_3)
5 - access("TEAM_ID"="WBXT"."TEAM_ID")
7 - access("ACT_ID"="ACCOUNT_ID")
14 - filter("DEFAULT_YN"=:SYS_B_1)
15 - access("BROKER_ID"=:SYS_B_0)
17 - access("INST_QUERY_ID"=:SYS_B_2)
18 - access("WDSD"."DATA_SETTING_ID"=NVL("Y"."DATA_SETTING_ID","DATA_SETTING_ID"))
19 - access("ATTR2"="FILTER_TOKEN")
Column Projection Information (identified by operation id):
-----------------------------------------------------------
1 - SUM("CASH_VALUE")[22]
2 - SYSDEF[4], SYSDEF[0], SYSDEF[1], SYSDEF[84], SYSDEF[0]
3 - "WBXT".ROWID[ROWID,10], "WBXT"."BROKER_ID"[NUMBER,22], "WBXT"."TEAM_ID"[VARCHAR2,200], "BO_TEAM_X_ACCOUNT".ROWID[ROWID,10], "ACCOUNT_ID"[VARCHAR2,200], "TEAM_ID"[VARCHAR2,200]
4 - "WBXT".ROWID[ROWID,10], "WBXT"."BROKER_ID"[NUMBER,22], "WBXT"."TEAM_ID"[VARCHAR2,200]
5 - "BO_TEAM_X_ACCOUNT".ROWID[ROWID,10], "ACCOUNT_ID"[VARCHAR2,200], "TEAM_ID"[VARCHAR2,200]
6 - (#keys=0) SUM("CASH_VALUE")[22]
7 - (#keys=1) "ACT_ID"[VARCHAR2,20], "ACCOUNT_ID"[VARCHAR2,200], "FILTER_TOKEN"[VARCHAR2,200], "AM".ROWID[ROWID,10], "ATTR2"[VARCHAR2,50], "CASH_VALUE"[NUMBER,22]
8 - "FILTER_TOKEN"[VARCHAR2,200], "AM".ROWID[ROWID,10], "ACT_ID"[VARCHAR2,20], "CASH_VALUE"[NUMBER,22], "ATTR2"[VARCHAR2,50]
9 - "FILTER_TOKEN"[VARCHAR2,200], "AM".ROWID[ROWID,10], "ATTR2"[VARCHAR2,50]
10 - "FILTER_TOKEN"[VARCHAR2,200]
11 - (#keys=1) "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
12 - "WEB_DATA_SETTING".ROWID[ROWID,10], "DATA_SETTING_ID"[NUMBER,22], "BROKER_ID"[NUMBER,22], "DEFAULT_YN"[VARCHAR2,1], "Y".ROWID[ROWID,10], "INST_QUERY_ID"[NUMBER,22],
"Y"."DATA_SETTING_ID"[NUMBER,22], "WDSD".ROWID[ROWID,10], "WDSD"."DATA_SETTING_ID"[NUMBER,22], "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
13 - "WEB_DATA_SETTING".ROWID[ROWID,10], "DATA_SETTING_ID"[NUMBER,22], "BROKER_ID"[NUMBER,22], "DEFAULT_YN"[VARCHAR2,1], "Y".ROWID[ROWID,10], "INST_QUERY_ID"[NUMBER,22],
"Y"."DATA_SETTING_ID"[NUMBER,22]
14 - "WEB_DATA_SETTING".ROWID[ROWID,10], "DATA_SETTING_ID"[NUMBER,22], "BROKER_ID"[NUMBER,22], "DEFAULT_YN"[VARCHAR2,1]
15 - "WEB_DATA_SETTING".ROWID[ROWID,10], "BROKER_ID"[NUMBER,22]
16 - (#keys=0) "Y".ROWID[ROWID,10], "INST_QUERY_ID"[NUMBER,22], "Y"."DATA_SETTING_ID"[NUMBER,22]
17 - "Y".ROWID[ROWID,10], "INST_QUERY_ID"[NUMBER,22], "Y"."DATA_SETTING_ID"[NUMBER,22]
18 - "WDSD".ROWID[ROWID,10], "WDSD"."DATA_SETTING_ID"[NUMBER,22], "WDSD"."FILTER_TOKEN"[VARCHAR2,200]
19 - "AM".ROWID[ROWID,10], "ATTR2"[VARCHAR2,50]
20 - "AM".ROWID[ROWID,10], "ACT_ID"[VARCHAR2,20], "CASH_VALUE"[NUMBER,22]
21 - "ACCOUNT_ID"[VARCHAR2,200]
22 - "ACCOUNT_ID"[VARCHAR2,200]
23 - "C0"[VARCHAR2,200]
178 rows selected.
Elapsed: 00:00:00.13
SQL>
|
|
|
Re: Tuning help needed [message #525752 is a reply to message #523096] |
Wed, 05 October 2011 02:55 |
|
LNossov
Messages: 318 Registered: July 2011 Location: Germany
|
Senior Member |
|
|
Your sql can be improved further. Check please, if optimizer stats for account_summary are up to date. If not, regather them and try once more with the last sql.
If the stats are OK, then try please the following sql:
WITH replist
AS (SELECT /*+ materialize */ DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT
wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = 48270
AND DEFAULT_YN = 'Y') X
WHERE inst_query_id = 1385776) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id)
rep_set),
actlist
AS (SELECT /*+ materialize */
account_id
FROM web_team_x_account wtxa, web_broker_x_team wbxt
WHERE wbxt.broker_id = 48270 AND wtxa.team_id = wbxt.team_id),
rslt AS (SELECT act_id, cash_value
FROM account_summary am
WHERE attr2 IN (SELECT FILTER_TOKEN FROM replist))
SELECT
SUM (cash_value)
FROM rslt
WHERE act_id in (SELECT account_id FROM actlist);
If you don't observe any improvement, then send to me your metadata please:
declare
ccc clob;
sss clob := 'WITH replist
AS (SELECT DISTINCT rep_set.FILTER_TOKEN
FROM (SELECT DISTINCT
wdsd.data_setting_id, wdsd.FILTER_TOKEN --- RR2
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 = 48270
AND DEFAULT_YN = 'Y') X
WHERE inst_query_id = 1385776) wiq
WHERE wiq.data_setting_id = wdsd.data_setting_id)
rep_set),
actlist
AS (SELECT
account_id
FROM web_team_x_account wtxa, web_broker_x_team wbxt
WHERE wbxt.broker_id = 48270 AND wtxa.team_id = wbxt.team_id),
rslt AS (SELECT act_id, cash_value
FROM account_summary am
WHERE attr2 IN (SELECT FILTER_TOKEN FROM replist))
SELECT
SUM (cash_value)
FROM rslt
WHERE act_id in (SELECT account_id FROM actlist)';
begin
dbms_sqldiag.export_sql_testcase(directory=>'DATA_PUMP_DIR',sql_text=>sss, user_name=>'<YOUR USER NAME>', testcase_name =>'LEO', testcase => ccc);
end;
/
Please don't forget to replace <YOUR USER NAME> with your real user name. You need some privileges for execution, so you could do that as dba or sysdba user.
The result you will find in the DATA_PUMP_DIRECTORY (for the path look please into dba_directories). All the testcase files should have LEO as a prefix in their names. You can use tar to get them into one file, then compress this file and upload the result or send directly to lnossov@yahoo.de.
Don't worry about your data, I'll receive only metadata.
|
|
|
Goto Forum:
Current Time: Fri Jan 10 16:38:46 CST 2025
|