Estimation of lines wrong with the size of the dynamic partition

Hi all

Version 11.1. RAC 4 knots. I met a sql that runs slowly because the bad LINES estimate. Here's the exectuion its plan.
Please note that the plan is just a part of the plan real exectuion. And I have collected statistics for all the tables involved, so I think that statistics should be updated.

Please see below. CBO estimated that only 640 lines for step 5 and 115 for this SQL totall. But the real result was almost 14K lines.
I don't know if the CBO made this mistake because of the size of the dynamic partition?
PLAN_TABLE_OUTPUT
Plan hash value: 2984909170
--------------------------------------------------------------------------------------------------------------------
| Id  | Operation                | Name                    | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
--------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT         |                         |   115 | 33005 |  2801   (8)| 00:00:09 |       |       |
|   1 |  NESTED LOOPS            |                         |   115 | 33005 |  2801   (8)| 00:00:09 |       |       |
|   2 |   PARTITION LIST ALL     |                         |     1 |   201 |  1482   (5)| 00:00:05 |     1 |    30 |
|*  3 |    TABLE ACCESS FULL     | OPT_ACCT_ASDN_TYPE2_DIM |     1 |   201 |  1482   (5)| 00:00:05 |     1 |    30 |
|   4 |   PARTITION LIST ITERATOR|                         |   640 | 55040 |  1319  (12)| 00:00:05 |   KEY |   KEY |
|*  5 |    TABLE ACCESS FULL     | OPT_FUND_GEN_SPNDG_FCT  |   640 | 55040 |  1319  (12)| 00:00:05 |   KEY |   KEY |
--------------------------------------------------------------------------------------------------------------------
But I made another simple test, in which I just used a predict as partition_key =: b. the exectuion plan resembles
PLAN_TABLE_OUTPUT
Plan hash value: 1115434777
----------------------------------------------------------------------------------------------------------------
| Id  | Operation             | Name                   | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
----------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT      |                        |   980K|    80M|  1390  (17)| 00:00:05 |       |       |
|   1 |  PARTITION LIST SINGLE|                        |   980K|    80M|  1390  (17)| 00:00:05 |   KEY |   KEY |
|*  2 |   TABLE ACCESS FULL   | OPT_FUND_GEN_SPNDG_FCT |   980K|    80M|  1390  (17)| 00:00:05 |   KEY |   KEY |
----------------------------------------------------------------------------------------------------------------
The estimate is more reasonable this time. Can someone show me why CBO made this mistake or why think CBO, there are only 600 lines while in reality there are more than 20 k lines.

Best regards
Leon

Published by: user12064076 on March 2, 2011 12:10 AM

Published by: user12064076 on March 2, 2011 01:01

Published by: user12064076 on March 2, 2011 01:11

The 'A-Time' is known to be wrong sometimes. However, the "buffers" are correct.
So the reading of the partition of the fact Table was 14Mo scan (1804 puts buffer @8 KB each). Which is really not much.
Yes, the cardinality estimate is off, but for a scan of 14Mo Oracle effort is not very high.

Cardinality for the recovery of the fact table is based on the statistics of column for the BUS_UNIIT_SKID and the ACCT_SKID. Because Oracle does not know what BUS_UNIT_SKID and ACCT_SKID values will be extracted from the Dimension table that results in the query, it can't really come up with an accurate estimate - even more if the data are biased.

From the column of table-level statistics, the optimizer knows how many distinct values of BUS_UNIT_SKID exist in the table.
From the column of table-level statistics, the optimizer knows how many distinct values of ACCT_SKID exist in the table.

But for a lost combination (BUS_UNIT_SKID, ACCT_SKID) in any unknown partition (the ' unknown' because it does not know the values or the partition during the query optimization) you can calculate an estimate only - the combined cardinality estimate is generally

(somewhat simplified)

Estimated_Number_of_Rows_of_Unknown_Partition  X     (1/Distinct_BUS_UNIT_SKIDs  X  1/Distinct_ACCT_SKIDs)
OR
Estimated_Number_of_Rows_of_Unknown_Partition  X    (5% estimate  X 5% estimate)

that will be very low.

You can run a plan to explain the "simplified" with the 10053 EVENT query

alter session set events '10053 trace name context forever, level 1';
explain plan for SELECT ......
exit

and display the trace file generated for more information on how Oracle considers the cardinality.

Your problem with the complex query is not likely here. You have to restyle the entire query instead of focusing on the estimation of cardinality for this fact table.
The query can be modified to help identify the Partition - Partition pruning - advance statistics?
The query can be modified in order to carry out the operations in a different sequence - get first performance and the effort of each step of the query Plan.

(BTW: the Dimension table reading was the most expensive part of this performance)

Hemant K Collette

Published by: Hemant K Collette on March 3, 2011 11:50

Tags: Database

Similar Questions

Maybe you are looking for

  • C55-b860 satellite is not booting

    Hi all I have a Satellite laptop c55, b860 which is not booting unfortunately. I disassembled it and deleted all the components that are connected to the MB, including hard drive, keyboard, and touchpad and also changed ram, but still the laptop does

  • HP OFFICE NETWORK CONTROLLER MISSING IN DEVICE MANAGER

    I can't connect to the wi - fi network because the network controller is missing in Device Manager. Please help with link where I can download the right software to. My hardware ID as it is in Device Manager - Properties - Hardware ID is PCI\VEN_1814

  • Video call Tango for Atrix came out :-)

    Finally a videoconference for Atrix application out that cell phone users can use too (iPhone, Android). I have not yet tried, but I hope that it works.

  • Remove line home pg up, pg dn buttons does not

    Laptop HP G60 - 243CL PrtSc remove line home pg up, pg dn buttons does not. they simply stop for some odd reason. How to fix? Thank you laptop is under warranty Bill

  • C 64 Vista 64/security update for SQL server 2005 Service Pack 3 (KB970892) problem code

    I get a request for update update of SQL server 2005, (not even sure if I need the SQL code on my laptop) and it never ends. It errors. It seems to open a box to find a file called (sqlrun_sql.msi) this file does not exist on my system. Unable to rei