Re: Potential Issue with Redundant Restriction Clauses in get_parameterized_baserel_size for PARTITIONED_REL

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Richard Guo <guofenglinux(at)gmail(dot)com>, huyajun <hu_yajun(at)qq(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, feichanghong(at)qq(dot)com
Subject: Re: Potential Issue with Redundant Restriction Clauses in get_parameterized_baserel_size for PARTITIONED_REL
Date: 2024-11-27 02:26:15
Message-ID: 1763158.1732674375@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> It would be good to understand why get_parameterized_baserel_size()
> bothers accounting for the baserestrictinfo quals and does not just do
> clauselist_selectivity() on param_clauses alone and multiply by
> rel->rows (which should already account for the baserestrictinfo).

One reason is that clauselist_selectivity does not necessarily
treat all the clauses independently. For example, if "x > 1"
is in one list and "x < 4" is in the other, you'll get very
different (and worse) results if you keep the lists separate
and just multiply their selectivities together.

We do have per-RestrictInfo selectivity caching that eliminates
most of the apparent inefficiency in this.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michail Nikolaev 2024-11-27 02:27:00 Re: Strange assertion in procarray.c
Previous Message David Rowley 2024-11-27 02:10:07 Re: Potential Issue with Redundant Restriction Clauses in get_parameterized_baserel_size for PARTITIONED_REL