On Tue, Feb 6, 2024 at 12:06 AM Ilia Evdokimov <ilya.evdoki...@tantorlabs.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).