Re: Optimizer estimated cardinality very low

From: Daniel Coello <coello.daniel_at_gmail.com>
Date: Tue, 27 Oct 2020 10:12:24 -0400
Message-ID: <CADX5pQVk8=2m+H66b9eXFB=YrF2B1P0-XELeOLtcj06g8tkjsQ_at_mail.gmail.com>



Hello, Nenad

Just to clarify, the July partition is the one giving us the very low estimate and does not use the sanity check method.

Having said that, we could test setting a higher value for the column group in the July partition to match what June percentage is and test how that impacts the optimizer. I'll have to look at that process if this is a valid approach.

Thanks,

On Tue, Oct 27, 2020 at 9:05 AM Noveljic Nenad <nenad.noveljic_at_vontobel.com> wrote:

> Hi Daniel,
>
>
>
> *“NUM_DISTINCT for the column_group in July are lower than
> ORDR_RQST_NUMBER instead of being equal or higher.”*
>
>
>
> This is exactly the reason that sanity check kicks in.
>
>
>
>
>
> *“ This happens across other partitions but the estimation doesn't seem
> impacted by this alone.”*
>
>
>
> There is some tolerance range. Set num_distinct for SYS_STU4S$4GK1UDMC2M8$MI#W6QS_
> of the June partition to a sufficiently low value for sanity check to kick
> in. Then you should get sel = 1.0 and a “good” cardinality estimate for
> your case.
>
>
>
>
>
> “*but the estimation doesn't seem impacted by this alone.”*
>
>
>
> Histogram on ORDR_RQST_DATE is apparently another prerequisite for the
> sanity check.
>
>
>
> Best regards,
>
>
>
> Nenad
>
>
>
> https://nenadnoveljic.com/blog
>
>
>
>
>
> *From:* Daniel Coello <coello.daniel_at_gmail.com>
> *Sent:* Montag, 26. Oktober 2020 18:07
> *To:* Noveljic Nenad <nenad.noveljic_at_vontobel.com>
> *Cc:* ORACLE-L (oracle-l_at_freelists.org) <oracle-l_at_freelists.org>
> *Subject:* Re: Optimizer estimated cardinality very low
>
>
>
>
>
> Hi Nenand.
>
>
>
> For when the interval when the estimation is good:
>
> ...
>
> Join ColGroups for ORDER_REQST[ORDER_REQST] and ORDER_DETL[ORDER_DETL] :
> Using cdn sanity check
>
> ...
>
>
>
> Below is some information relevant to the columns:
>
> ORDER_REQST
>
>
>
> PARTITION_NAME
>
> COLUMN_NAME
>
> NUM_DISTINCT
>
> NUM_BUCKETS
>
> SAMPLE_SIZE
>
> HISTOGRAM
>
> NUM_ROW IN PARTITION
>
> JULY
>
> SYS_P971481
>
> ORDR_RQST_DATE
>
> 3
>
> 3
>
> 26895392
>
> FREQUENCY
>
> 26895392
>
> SYS_P971481
>
> SYS_STU4S$4GK1UDMC2M8$MI#W6QS_
>
> 26636288
>
> 1
>
> 26895392
>
> NONE
>
> 26895392
>
> SYS_P971481
>
> ORDR_RQST_NUMBER
>
> 26895392
>
> 1
>
> 26895392
>
> NONE
>
> 26895392
>
> JUNE
>
> SYS_P964661
>
> ORDR_RQST_DATE
>
> 4
>
> 4
>
> 17506471
>
> FREQUENCY
>
> 17506471
>
> SYS_P964661
>
> SYS_STU4S$4GK1UDMC2M8$MI#W6QS_
>
> 15794176
>
> 1
>
> 17506471
>
> NONE
>
> 17506471
>
> SYS_P964661
>
> ORDR_RQST_NUMBER
>
> 15649792
>
> 1
>
> 17506471
>
> NONE
>
> 17506471
>
> ORDER_DETL
>
>
>
> PARTITION_NAME
>
> COLUMN_NAME
>
> NUM_DISTINCT
>
> NUM_BUCKETS
>
> SAMPLE_SIZE
>
> HISTOGRAM
>
> NUM_ROW IN PARTITION
>
> JULY
>
> SYS_P971761
>
> ORDR_RQST_DATE
>
> 3
>
> 3
>
> 32314200
>
> FREQUENCY
>
> 32314200
>
> SYS_P971761
>
> SYS_STU4S$4GK1UDMC2M8$MI#W6QS_
>
> 26636288
>
> 1
>
> 32314200
>
> NONE
>
> 32314200
>
> SYS_P971761
>
> ORDR_RQST_NUMBER
>
> 26984448
>
> 1
>
> 32314200
>
> NONE
>
> 32314200
>
> JUNE
>
> SYS_P964866
>
> ORDR_RQST_DATE
>
> 4
>
> 4
>
> 21814573
>
> FREQUENCY
>
> 21814573
>
> SYS_P964866
>
> SYS_STU4S$4GK1UDMC2M8$MI#W6QS_
>
> 15794176
>
> 1
>
> 21814573
>
> NONE
>
> 21814573
>
> SYS_P964866
>
> ORDR_RQST_NUMBER
>
> 15649792
>
> 1
>
> 21814573
>
> NONE
>
> 21814573
>
>
>
> Things that have been pointed out to me or relevant to the env:
>
> - NUM_DISTINCT for the column_group in July are lower than
> ORDR_RQST_NUMBER instead of being equal or higher. This happens across
> other partitions but the estimation doesn't seem impacted by this alone.
>
> - I added the NUM_ROW values from the partitions for comparison with the
> total number of rows in it.
>
> - ORDER_DETL columns' values should exist in ORDER_REQST, there shouldn't
> be an orphan row which in real counts you can see.
>
>
>
>
>
> - The actual count for distincts are:
>
> *July:*
>
> ORDER_REQST
>
> ORDR_RQST_NUMBER: 26846523
>
> COL_GROUP ( ORDR_RQST_NUMBER , ORDR_RQST_DATE ): 26846523
>
>
>
> ORDER_DETL
>
> ORDR_RQST_NUMBER: 26846523
>
> COL_GROUP ( ORDR_RQST_NUMBER , ORDR_RQST_DATE ) : 26846523
>
>
>
> *June:*
>
> ORDER_REQST
>
> ORDR_RQST_NUMBER : 15683040
>
> COL_GROUP ( ORDR_RQST_NUMBER , ORDR_RQST_DATE ) : 15683040
>
>
>
> ORDER_DETL
>
> ORDR_RQST_NUMBER : 15683040
>
> COL_GROUP ( ORDR_RQST_NUMBER , ORDR_RQST_DATE ) : 15683040
>
>
>
> Thanks,
>
>
>
> ____________________________________________________
>
> Please consider the environment before printing this e-mail.
>
> Bitte denken Sie an die Umwelt, bevor Sie dieses E-Mail drucken.
>
>
> Important Notice
> This message is intended only for the individual named. It may contain
> confidential or privileged information. If you are not the named addressee
> you should in particular not disseminate, distribute, modify or copy this
> e-mail. Please notify the sender immediately by e-mail, if you have
> received this message by mistake and delete it from your system.
> Without prejudice to any contractual agreements between you and us which
> shall prevail in any case, we take it as your authorization to correspond
> with you by e-mail if you send us messages by e-mail. However, we reserve
> the right not to execute orders and instructions transmitted by e-mail at
> any time and without further explanation.
> E-mail transmission may not be secure or error-free as information could
> be intercepted, corrupted, lost, destroyed, arrive late or incomplete. Also
> processing of incoming e-mails cannot be guaranteed. All liability of
> Vontobel Holding Ltd. and any of its affiliates (hereinafter collectively
> referred to as "Vontobel Group") for any damages resulting from e-mail use
> is excluded. You are advised that urgent and time sensitive messages should
> not be sent by e-mail and if verification is required please request a
> printed version. Please note that all e-mail communications to and from the
> Vontobel Group are subject to electronic storage and review by Vontobel
> Group. Unless stated to the contrary and without prejudice to any
> contractual agreements between you and Vontobel Group which shall prevail
> in any case, e-mail-communication is for informational purposes only and is
> not intended as an offer or solicitation for the purchase or sale of any
> financial instrument or as an official confirmation of any transaction.
> The legal basis for the processing of your personal data is the legitimate
> interest to develop a commercial relationship with you, as well as your
> consent to forward you commercial communications. You can exercise, at any
> time and under the terms established under current regulation, your rights.
> If you prefer not to receive any further communications, please contact
> your client relationship manager if you are a client of Vontobel Group or
> notify the sender. Please note for an exact reference to the affected group
> entity the corporate e-mail signature. For further information about data
> privacy at Vontobel Group please consult www.vontobel.com.
>

-- 
Daniel Coello Villacis

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Oct 27 2020 - 15:12:24 CET

Original text of this message