Re: pg_stat_advisor extension

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_stat_advisor extension
Date: 2024-02-08 00:00:00
Message-ID: CACJufxHJFf3f4a2VPp40ibQMLtKn=FnLbxNsx1tGkWZoq1jvxQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 6, 2024 at 12:06 AM Ilia Evdokimov
<ilya(dot)evdokimov(at)tantorlabs(dot)com> wrote:
>
> Hi hackers,
>
> I'm reaching out again regarding the patch with new extension 'pg_stat_advisor' aimed at enhancing query plan efficiency through the suggestion of creating statistics.
>
> I understand the community is busy, but I would greatly value any feedback or thoughts on this extension.
>

+ /* Define custom GUC variables. */
+ DefineCustomRealVariable("pg_stat_advisor.suggest_statistics_threshold",
+ "Set the threshold for actual/estimated rows",
+ "Zero disables suggestion of creating statistics",
+ &pg_stat_advisor_suggest_statistics_threshold,
+ 0.0,
+ 0.0,
+ INT_MAX,
+ PGC_SUSET,
+ 0,
+ NULL,
+ NULL,
+ NULL);

INT_MAX
should be 1.0?

+ if (!FindExtendedStatisticsOnVars(&rte->relid, colmap))
+ {
+ ereport(NOTICE, (errmsg("pg_stat_advisor suggestion: CREATE
STATISTICS %s %s FROM %s",
+ stat_name, create_stat_stmt, rel_name),
+ errhidestmt(true)));
+ }
now CREATE STATISTICS, the statistics name is optional.
but here you explicitly mention the statistics kind would be great.

+ elog(DEBUG1, "Estimated=%f, actual=%f, error=%f: plan=%s",
+ plan->plan_rows,
+ planstate->instrument->ntuples,
+ planstate->instrument->ntuples / plan->plan_rows,
+ nodeToString(plan));

` error=%f` seems not that right.
Also since the documentation is limited, more comments explaining
SuggestMultiColumnStatisticsForNode would be great.
overall the comments are very little, it should be more (that's my opinion).

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message James Coleman 2024-02-08 00:12:25 Re: Question about behavior of deletes with REPLICA IDENTITY NOTHING
Previous Message Peter Smith 2024-02-07 23:04:16 Re: Question about behavior of deletes with REPLICA IDENTITY NOTHING