Re: Statistics Import and Export - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Statistics Import and Export
Date
Msg-id CADkLM=cb1g7FupStPeo2rZn5EDARUrjQWdfBAXHSckZU8Ppnng@mail.gmail.com
Whole thread Raw
In response to Re: Statistics Import and Export  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: Statistics Import and Export
List pgsql-hackers
On Mon, Oct 14, 2024 at 3:40 PM Corey Huinker <corey.huinker@gmail.com> wrote:
However, this function seems to accept -1 for the relpages parameter. Below is an example of execution:
---
postgres=> CREATE TABLE data1(c1 INT PRIMARY KEY, c2 VARCHAR(10));
CREATE TABLE
postgres=> SELECT pg_set_relation_stats('data1', relpages=>-1);
 pg_set_relation_stats
-----------------------
 t
(1 row)
postgres=> SELECT relname, relpages FROM pg_class WHERE relname='data1';
 relname | relpages
---------+----------
 data1   |       -1
(1 row)
---

The attached patch modifies the pg_set_relation_stats function to work as described in the manual.

Regards,
Noriyoshi Shinoda

Accepting -1 is correct. I thought I had fixed that in a recent patch. Perhaps signals got crossed somewhere along the way.

Just to be sure, I went back to v29, fixed a typo and some whitespace issues in stats_import.out, confirmed that it passed regression tests, then changed the relpages lower bound from -1 back to 0, and sure enough, the regression test for pg_upgrade failed again.

It seems that partitioned tables have a relpages of -1, so regression tests involving tables alpha_neg and alpha_pos (and 35 others, all seemingly partitioned) fail. So it was the docs that were wrong, not the code.

e839c8ecc9352b7754e74f19ace013c0c0d18613 doesn't include the stuff that modified pg_dump/pg_upgrade, so it wouldn't have turned up this problem.

pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Add contrib/pg_logicalsnapinspect
Next
From: David Rowley
Date:
Subject: Re: Changing the default random_page_cost value