> 1. Allow relpages to be set to -1 (partitioned tables with partitions have > this value after ANALYZE). > 2. Turn off autovacuum on tables (where possible) if they are going to be the > target of pg_set_relation_stats(). > 3. Allow pg_set_relation_stats to continue past an out-of-range detection on > one attribute, rather than immediately returning false
Thank you for developing this feature.
If the relpages option contains -1 only for partitioned tables, shouldn't
pg_set_relation_stats restrict the values that can be
specified by table type? The attached patch limits the value to -1 or more if
the target
is a partition table, and 0 or more otherwise.
Changing relpages to -1 on a non-partitioned table seems to significantly
change the execution plan.
---
postgres=> EXPLAIN (COSTS OFF) SELECT * FROM data1 WHERE c1=1000;
QUERY PLAN
--------------------------------------
Index Scan using data1_pkey on data1
Index Cond: (c1 = 1000)
(2 rows)
postgres=> SELECT pg_set_relation_stats('data1', relpages=>-1);
pg_set_relation_stats
-----------------------
t
(1 row)
postgres=> EXPLAIN (COSTS OFF) SELECT * FROM data1 WHERE c1=1000;
QUERY PLAN
---------------------------------------
Bitmap Heap Scan on data1
Recheck Cond: (c1 = 1000)
-> Bitmap Index Scan on data1_pkey
Index Cond: (c1 = 1000)
(4 rows)
---
Regards,
Noriyoshi Shinoda
From: Corey Huinker <[email protected]>
Sent: Saturday, October 19, 2024 10:00 AM
To: Jeff Davis <[email protected]>
Cc: Shinoda, Noriyoshi (SXD Japan FSIP) <[email protected]>; jian he
<[email protected]>; Matthias van de Meent
<[email protected]>; Bruce Momjian <[email protected]>; Tom Lane
<[email protected]>; Nathan Bossart <[email protected]>; Magnus
Hagander <[email protected]>; Stephen Frost <[email protected]>; Ashutosh
Bapat <[email protected]>; Peter Smith <[email protected]>;
PostgreSQL Hackers <[email protected]>; [email protected]
Subject: Re: Statistics Import and Export
Patch that allows relation_statistics_update to continue after one failed stat
(0001) attached, along with bool->void change (0002).
Once more, with feeling:
pg_set_relation_stats_patch_v1.diff
Description: pg_set_relation_stats_patch_v1.diff
