Re: Why does the planner reduce the planned rows when filtering single values in an array

From: Isaiah Langford <ilangford(at)ushrauto(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why does the planner reduce the planned rows when filtering single values in an array
Date: 2023-04-21 23:02:55
Message-ID: SN6PR15MB2397318FC09522BA7B2030D2D4609@SN6PR15MB2397.namprd15.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you Tom,

Every tool is a work in progress. Knowing it's just a fact of life for now is really helpful, I appreciate the response.
________________________________
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Sent: Saturday, April 22, 2023 12:43 AM
To: Isaiah Langford <ilangford(at)ushrauto(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Why does the planner reduce the planned rows when filtering single values in an array

Isaiah Langford <ilangford(at)ushrauto(dot)com> writes:
> Why is the planner expecting the number of rows to be reduced by the join filter? Is there any way I can correct the planner here?

I think you're running into a couple of issues here:

* ANALYZE fails to record any useful stats for a single-row table.
It can't form a histogram with only one entry, but it also fails to
put the value into the MCV list, because there's a heuristic that an
MCV must appear more than once. Possibly we could think harder
about what to do with such cases, but at the moment the planner has
no knowledge that the only value in single_value_table is "1".

* Even if it did know that, the logic in scalararraysel() is quite
inadequate for the case of "variable = ANY(variable)". It looks
like that's only been fleshed out for cases where one side or
the other is a constant.

Lot of unfinished work here :-(

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wen Yi 2023-04-22 03:08:41 Where to find the Makefile.global?
Previous Message senor 2023-04-21 21:55:09 Re: vacuum TOAST tables