Re: Statistics Import and Export

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Subject: Re: Statistics Import and Export
Date: 2024-03-11 08:50:33
Message-ID: Ze7F2b/8EtazZB3u@ip-10-97-1-34.eu-west-3.compute.internal
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Fri, Mar 08, 2024 at 01:35:40AM -0500, Corey Huinker wrote:
> Anyway, here's v7. Eagerly awaiting feedback.

Thanks!

A few random comments:

1 ===

+ The purpose of this function is to apply statistics values in an
+ upgrade situation that are "good enough" for system operation until

Worth to add a few words about "influencing" the planner use case?

2 ===

+#include "catalog/pg_type.h"
+#include "fmgr.h"

Are those 2 needed?

3 ===

+ if (!HeapTupleIsValid(ctup))
+ elog(ERROR, "pg_class entry for relid %u vanished during statistics import",

s/during statistics import/when setting statistics/?

4 ===

+Datum
+pg_set_relation_stats(PG_FUNCTION_ARGS)
+{
.
.
+ table_close(rel, ShareUpdateExclusiveLock);
+
+ PG_RETURN_BOOL(true);

Why returning a bool? (I mean we'd throw an error or return true).

5 ===

+ */
+Datum
+pg_set_attribute_stats(PG_FUNCTION_ARGS)
+{

This function is not that simple, worth to explain its logic in a comment above?

6 ===

+ if (!HeapTupleIsValid(tuple))
+ {
+ relation_close(rel, NoLock);
+ PG_RETURN_BOOL(false);
+ }
+
+ attr = (Form_pg_attribute) GETSTRUCT(tuple);
+ if (attr->attisdropped)
+ {
+ ReleaseSysCache(tuple);
+ relation_close(rel, NoLock);
+ PG_RETURN_BOOL(false);
+ }

Why is it returning "false" and not throwing an error? (if ok, then I think
we can get rid of returning a bool).

7 ===

+ * If this relation is an index and that index has expressions in
+ * it, and the attnum specified

s/is an index and that index has/is an index that has/?

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2024-03-11 09:09:29 Re: Add bump memory context type and use it for tuplesorts
Previous Message Svetlana Derevyanko 2024-03-11 08:38:40 Re: Add Index-level REINDEX with multiple jobs