Re: Non-Stored Generated Columns

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Non-Stored Generated Columns
Date: 2024-02-29 11:07:26
Message-ID: CAFCRh--Er21oPSb3n_WanuKsgr0UGeS4dJ26bqip2yN_RUeWxg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Feb 29, 2024 at 11:58 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
wrote:

> On Thu, 2024-02-29 at 10:55 +0100, Dominique Devienne wrote:
> > On Thu, Feb 29, 2024 at 10:03 AM Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
> wrote:
> > > You could use conditional indexes, but then you have to make sure that
> > > the optimizer knows it can use these indexes.
> >
> > I'm not following. Are you saying the planner is not good at that on its
> own?
> > I need to do something from my end???
>
> I wasn't sure, but now I tested: a conditional index can also be used
> by a cascading delete or update. So that's not a worry.
>

Great. Thanks a bunch for confirming for me!

> > Something I maybe didn't make clear. The XArc virtual columns are never
> accessed.
>
> Yes, they are. The query planner considers all indexes.
>

Not sure if I'm missing some terminology or something, to understand your
point.
The XArc columns are never explicitly SELECT'd by our code.
Nor are they used in any of our WHERE clauses.

So yes, the additional indexes our PFK pattern introduces make the pool of
indexes considered larger.
But I'm sure indexes on columns "not used at all in a statement" are
eliminated early and easily/cheaply,
w/o even getting into more complex consideration like statistics and co.
Aren't they? Thanks, --DD

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Or Cohen 2024-02-29 11:47:57 RE: SUSE repositories not longer available
Previous Message Laurenz Albe 2024-02-29 10:58:31 Re: Non-Stored Generated Columns