From: | Andrei Lepikhov <lepihov(at)gmail(dot)com> |
---|---|
To: | David Rowley <dgrowleyml(at)gmail(dot)com>, ming wei tan <mingwei(dot)tc(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-bugs(at)lists(dot)postgresql(dot)org |
Subject: | Re: BUG #18643: EXPLAIN estimated rows mismatch |
Date: | 2024-10-03 04:23:14 |
Message-ID: | bc9562f9-5e6b-498d-9243-697a56961292@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On 10/3/24 03:57, David Rowley wrote:
> On Thu, 3 Oct 2024 at 07:17, ming wei tan <mingwei(dot)tc(at)gmail(dot)com> wrote:
>>
>> On 1/10/2024 18:43, Tom Lane wrote:
>>> In any case, in this toy example that lacks an ANALYZE step,
>>> the selectivity estimates are mostly going to be garbage.
>>
>> Thanks for the replies. I'm just checking if a bug is present here
>> is a bug. Even with ANALYZE, the first EXPLAIN estimates more rows
>> compared to the second, even though the second WHERE clause is
>> less restrictive.
>
> I think you already checked that and Tom answered mentioning the
> reason that this happens.
>
> We certainly could do better here, but, as Tom mentioned your example
> does not seem convincing enough to warrant much effort.
>
> You should read the commit message in [1] as that might help you
> understand the project's point of view for these sort of
> optimisations. See in particular the first sentence of the second
> paragraph.
I can agree with the source reason. But presence of prepqual.c makes it
less clear:
Optimiser already attempts to remove duplicated ORs by the
find_duplicate_ors function. And does it in some strange manner:
explain
SELECT oid,relname FROM pg_class WHERE oid=1 OR oid=1;
Index Scan using pg_class_oid_index on pg_class
Index Cond: (oid = '1'::oid)
explain
SELECT oid,relname FROM pg_class WHERE oid=1 OR oid=1 OR oid=2;
Seq Scan on pg_class
Filter: ((oid = '1'::oid) OR (oid = '1'::oid) OR (oid = 2))
So, we already pass through the OR clauses. Why not to check semi-equal
clauses and remove duplicates even if not all clauses are such
duplicates? At least, it continually raises users' questions.
--
regards, Andrei Lepikhov
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-10-03 04:40:02 | Re: BUG #18643: EXPLAIN estimated rows mismatch |
Previous Message | David G. Johnston | 2024-10-03 04:19:49 | Fix the description of what Schema Usage controls |