Re: Inconsistent use of relpages = -1

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Inconsistent use of relpages = -1
Date: 2024-10-24 02:01:47
Message-ID: 4f580871f8386d35261e7c46ca0af8abb3969e2c.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2024-10-23 at 10:05 -0700, Jeff Davis wrote:
> On Wed, 2024-10-23 at 04:47 +0200, Laurenz Albe wrote:
> > On Tue, 2024-10-22 at 10:41 -0700, Jeff Davis wrote:
> > > I attached a patch that creates partitioned tables with relpages=-
> > > 1,
> > > and updates the docs.
> >
> > Does this need any changes for pg_upgrade?
>
> pg_upgrade would go through the same DDL path, so I expect it would be
> set to -1 in the upgraded cluster anyway. Are you seeing something
> different?

No; I was too lazy to check, so I asked.

> In any case, the change is just meant to improve consistency and
> documentation. I didn't intend to create a hard guarantee that it would
> always be -1, so perhaps I should make the documentation more vague
> with "may be" instead of "is"?

Reading the thread an Tom's comments again, I get the impression that there
are two states that we consider OK:

- "relpages" and "reltuples" are both 0
- "relpages" is -1 and "reltuples" is greater than 0

What you write above indicates that "relpages" = 0 and "reltuples" > 0
would also be acceptable.

As long as the code does not mistakenly assume that a partitioned table
is empty, and as long as the documentation is not confusing, anything
is fine with me. Currently, I am still a bit confused.

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-10-24 02:10:31 Re: Using Expanded Objects other than Arrays from plpgsql
Previous Message Tom Lane 2024-10-24 01:57:14 Re: Commutation of array SOME/ANY and ALL operators