Execution Plan [message #248266] |
Thu, 28 June 2007 08:51 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
Recently upgrade the db from 9i to 10g,and one statement has performance issue.
Here is the statement,I know that it was poorly written.
select fls.fill_line_sts_cd, count(fls.fill_line_sts_cd)
from ddf_owner.ddf_fill_line_sts fls, ddf_owner.ddf_organic_request_lines rl
where fls.rqst_id = rl.rqst_id and fls.rqst_line_id = rl.rqst_line_id and
fls.FILL_LINE_STS_CD not in ('C', 'H') and
fls.RQST_ID in
(select distinct scl.RQST_ID from ddf_owner.ddf_shpmnt_cntnr_list scl where scl.SHPMNT_ID =29026 )
group by fls.fill_line_sts_cd
In our QAR db the execution plan is
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6 | 180 | 6 |
| 1 | HASH GROUP BY | | 6 | 180 | 6 |
| 2 | NESTED LOOPS | | 219 | 6570 | 5 |
| 3 | NESTED LOOPS | | 219 | 4599 | 3 |
| 4 | SORT UNIQUE | | 19 | 190 | 1 |
| 5 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 19 | 190 | 1 |
| 6 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 21 | | 1 |
| 7 | TABLE ACCESS BY INDEX ROWID | DDF_FILL_LINE_STS | 12 | 132 | 1 |
| 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 17 | | 1 |
| 9 | INDEX UNIQUE SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 1 | 9 | 1 |
-------------------------------------------------------------------------------------------------
but in our PRD db, the execution is
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5 | 150 | 288 |
| 1 | HASH GROUP BY | | 5 | 150 | 288 |
| 2 | HASH JOIN RIGHT SEMI | | 37668 | 1103K| 280 |
| 3 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 777 | 7770 | 1 |
| 4 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 887 | | 1 |
| 5 | TABLE ACCESS BY INDEX ROWID| DDF_FILL_LINE_STS | 1 | 11 | 1 |
| 6 | NESTED LOOPS | | 830K| 15M| 258 |
| 7 | INDEX FULL SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 2119K| 18M| 56 |
| 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 1 | | 1 |
-----------------------------------------------------------------------------------------------
we rebuilt the indexes in PRD ,and the records in QAR and PRD are almost same. No outlines were used in both 2 DBs. I have no idea why the execution plan is so different. BTW, the query ran well in 9i before the upgrade.Of course I can rewrite the query to fix the performance issue,but I want to know why the index was not used in my PRD database.
If anyone has any idea,please let me know.thanks.
Fei
|
|
|
|
Re: Execution Plan [message #248295 is a reply to message #248266] |
Thu, 28 June 2007 10:07 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
select fls.fill_line_sts_cd, count(fls.fill_line_sts_cd)
from ddf_owner.ddf_fill_line_sts fls, ddf_owner.ddf_organic_request_lines rl
where fls.rqst_id = rl.rqst_id and fls.rqst_line_id = rl.rqst_line_id and
fls.FILL_LINE_STS_CD not in ('C', 'H') and
fls.RQST_ID in
(select distinct scl.RQST_ID from ddf_owner.ddf_shpmnt_cntnr_list scl where scl.SHPMNT_ID =29026 )
group by fls.fill_line_sts_cd
Execution plan in QAR,
-------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6 | 180 | 6 |
| 1 | HASH GROUP BY | | 6 | 180 | 6 |
| 2 | NESTED LOOPS | | 219 | 6570 | 5 |
| 3 | NESTED LOOPS | | 219 | 4599 | 3 |
| 4 | SORT UNIQUE | | 19 | 190 | 1 |
| 5 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 19 | 190 | 1 |
| 6 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 21 | | 1 |
| 7 | TABLE ACCESS BY INDEX ROWID | DDF_FILL_LINE_STS | 12 | 132 | 1 |
| 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 17 | | 1 |
| 9 | INDEX UNIQUE SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 1 | 9 | 1 |
------------------------------------------------------------------------------------------------
Execution plan in RPD,
-----------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
-----------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5 | 150 | 288 |
| 1 | HASH GROUP BY | | 5 | 150 | 288 |
| 2 | HASH JOIN RIGHT SEMI | | 37668 | 1103K| 280 |
| 3 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 777 | 7770 | 1 |
| 4 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 887 | | 1 |
| 5 | TABLE ACCESS BY INDEX ROWID| DDF_FILL_LINE_STS | 1 | 11 | 1 |
| 6 | NESTED LOOPS | | 830K| 15M| 258 |
| 7 | INDEX FULL SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 2119K| 18M| 56 |
| 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 1 | | 1 |
-----------------------------------------------------------------------------------------------
Thanks
|
|
|
|
|
|
Re: Execution Plan [message #248357 is a reply to message #248266] |
Thu, 28 June 2007 13:48 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
QAR
<code>
SQL> select count(*) from ddf_owner.DDF_ORGANIC_REQUEST_LINES;
COUNT(*)
----------
2041122
SQL> select count(*) from ddf_owner.DDF_SHPMNT_CNTNR_LIST;
COUNT(*)
----------
861827
SQL> select count(*) from ddf_owner.DDF_FILL_LINE_STS;
COUNT(*)
----------
758403
</code>
PRD
<code>
SQL> select count(*) from ddf_owner.DDF_ORGANIC_REQUEST_LINES;
COUNT(*)
----------
2121339
SQL> select count(*) from ddf_owner.DDF_SHPMNT_CNTNR_LIST;
COUNT(*)
----------
964380
SQL> select count(*) from ddf_owner.DDF_FILL_LINE_STS;
COUNT(*)
----------
837110
</code>
|
|
|
Re: Execution Plan [message #248358 is a reply to message #248266] |
Thu, 28 June 2007 13:51 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
QAR
SQL> select count(*) from ddf_owner.DDF_ORGANIC_REQUEST_LINES;
COUNT(*)
----------
2041122
SQL> select count(*) from ddf_owner.DDF_SHPMNT_CNTNR_LIST;
COUNT(*)
----------
861827
SQL> select count(*) from ddf_owner.DDF_FILL_LINE_STS;
COUNT(*)
----------
758403
PRD
SQL> select count(*) from ddf_owner.DDF_ORGANIC_REQUEST_LINES;
COUNT(*)
----------
2121339
SQL> select count(*) from ddf_owner.DDF_SHPMNT_CNTNR_LIST;
COUNT(*)
----------
964380
SQL> select count(*) from ddf_owner.DDF_FILL_LINE_STS;
COUNT(*)
----------
837110
|
|
|
|
|
|
Re: Execution Plan [message #248363 is a reply to message #248266] |
Thu, 28 June 2007 14:07 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
To Anacedent:I am able to rewrite the code to get better performance.I just want to find the reason why it doesn't use indexes in my PRD environment.Thanks.
To Michel Cadot: is the execution plan I attached in my first thread you wanted? I just used
select * from table(dbms_xplan.dispay) to get the execution plan. Is there other command I can use to get the explain plan?Thanks.
To Michael_bialik: the stats are definitely not identical.however,I rebuilt the index and analyzed the table/indexes,but I still get the same result.
Thanks again for your guys' help.
|
|
|
|
Re: Execution Plan [message #248373 is a reply to message #248266] |
Thu, 28 June 2007 14:52 |
eggplant
Messages: 8 Registered: June 2007
|
Junior Member |
|
|
in PRD
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------
Plan hash value: 3400760556
---------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
---------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5 | 150 | 288 (52)| 00:00:04 |
| 1 | HASH GROUP BY | | 5 | 150 | 288 (52)| 00:00:04 |
|* 2 | HASH JOIN RIGHT SEMI | | 37668 | 1103K| 280 (50)| 00:00:04 |
|* 3 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 777 | 7770 | 1 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 887 | | 1 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| DDF_FILL_LINE_STS | 1 | 11 | 1 (0)| 00:00:01 |
| 6 | NESTED LOOPS | | 830K| 15M| 258 (47)| 00:00:04 |
| 7 | INDEX FULL SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 2119K| 18M| 56 (2)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 1 | | 1 (0)| 00:00:01 |
---------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("FLS"."RQST_ID"="SCL"."RQST_ID")
3 - filter("SCL"."RQST_ID" IS NOT NULL)
4 - access("SCL"."SHPMNT_ID"=29026)
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------
5 - filter("FLS"."FILL_LINE_STS_CD"<>'C' AND "FLS"."FILL_LINE_STS_CD"<>'H')
8 - access("FLS"."RQST_ID"="RL"."RQST_ID" AND "FLS"."RQST_LINE_ID"="RL"."RQST_LINE_ID")
24 rows selected.
in QAR
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------------------
Plan hash value: 4201419942
-----------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 6 | 180 | 6 (34)| 00:00:01 |
| 1 | HASH GROUP BY | | 6 | 180 | 6 (34)| 00:00:01 |
| 2 | NESTED LOOPS | | 219 | 6570 | 5 (20)| 00:00:01 |
| 3 | NESTED LOOPS | | 219 | 4599 | 3 (34)| 00:00:01 |
| 4 | SORT UNIQUE | | 19 | 190 | 1 (0)| 00:00:01 |
|* 5 | TABLE ACCESS BY INDEX ROWID| DDF_SHPMNT_CNTNR_LIST | 19 | 190 | 1 (0)| 00:00:01 |
|* 6 | INDEX RANGE SCAN | DDF_SHPMNT_CNTNR_LIST_A01 | 21 | | 1 (0)| 00:00:01 |
|* 7 | TABLE ACCESS BY INDEX ROWID | DDF_FILL_LINE_STS | 12 | 132 | 1 (0)| 00:00:01 |
|* 8 | INDEX RANGE SCAN | DDF_FILL_LINE_STS_A03 | 17 | | 1 (0)| 00:00:01 |
|* 9 | INDEX UNIQUE SCAN | DDF_ORGANIC_REQUEST_LINES_P01 | 1 | 9 | 1 (0)| 00:00:01 |
-----------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
5 - filter("SCL"."RQST_ID" IS NOT NULL)
6 - access("SCL"."SHPMNT_ID"=29026)
PLAN_TABLE_OUTPUT
-------------------------------------------------------------------------------------------------------------------
7 - filter("FLS"."FILL_LINE_STS_CD"<>'C' AND "FLS"."FILL_LINE_STS_CD"<>'H')
8 - access("FLS"."RQST_ID"="SCL"."RQST_ID")
9 - access("FLS"."RQST_ID"="RL"."RQST_ID" AND "FLS"."RQST_LINE_ID"="RL"."RQST_LINE_ID")
25 rows selected.
Thanks.
|
|
|