From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru> |
Cc: | David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, tomas(at)vondra(dot)me |
Subject: | Re: Incremental Sort Cost Estimation Instability |
Date: | 2024-11-08 03:25:29 |
Message-ID: | 8addc5e2-ed47-476f-9b01-ca8e6d3a762c@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 11/7/24 18:06, Alena Rybakina wrote:
> On 07.11.2024 08:57, Andrei Lepikhov wrote:
>> That happens because when estimating the number of groups, Postgres
>> doesn't consider EquivalenceClass, which can let him correct group
>> estimation at a low price.
>> It may be done inside the make_pathkeys_for_sortclauses_extended by
>> choosing a column with a lower number of distinct, but IMO, it is
>> better to do it at the moment of the number of groups estimation.
>>
>> Thoughts? Is it a real issue or just a non-practical corner case?
>>
>> The new version of the patch is attached.
>>
>> [1] https://www.postgresql.org/message-id/
>> flat/8742aaa8-9519-4a1f-91bd-364aec65f5cf%40gmail.com
>
> But you haven’t considered the case when you need to use non-cached
> values, for example, if ndistinct has already changed. Look, here x has
> a minimum ndistinct, and then column z:
> but the order of the columns does not change, as you can see.
I'm unsure what you mean by talking about 'cached value' or 'changed
ndistinct' even slightly.
Also, I don't understand the issue you tried to show with your examples.
My point was that an equality expression can be used to modify
statistics-based decisions on the number of groups. Look:
A.x, distincts = 1000
A.y, distincts = 10
After the filter 'A.x=A.y' it is impossible to get more than 10 groups
on the A.x as well as on the A.y column. So, we have a tool to correct
the estimation considering equivalence classes.
--
regards, Andrei Lepikhov
From | Date | Subject | |
---|---|---|---|
Next Message | Kirk Wolak | 2024-11-08 03:46:54 | PoC: Simplify recovery after dropping a table by LOGGING the restore LSN |
Previous Message | Amit Kapila | 2024-11-08 03:05:38 | Re: [bug fix] prepared transaction might be lost when max_prepared_transactions is zero on the subscriber |