| From: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
|---|---|
| To: | Tatsuya Kawata <kawatatatsuya0913(at)gmail(dot)com> |
| Cc: | "samimseih(at)gmail(dot)com" <samimseih(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: [PATCH] Add sampling statistics to autoanalyze log output |
| Date: | 2026-12-04 14:55:51 |
| Message-ID: | CAHGQGwEM-qrT1yLY3yZmP0AO5-m0R7HjQZsFWVv5veHGpmnXLQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Wed, Feb 11, 2026 at 12:19 AM Tatsuya Kawata
<kawatatatsuya0913(at)gmail(dot)com> wrote:
> If anyone has had a chance to look at this patch and has any comments or suggestions, I'd be more than happy to address them.
I'd like to revisit this patch. Here are some review comments on v4 patch:
- ereport(elevel,
- (errmsg("\"%s\": scanned %d of %u pages, "
- "containing %.0f live rows and %.0f dead rows; "
- "%d rows in sample, %.0f estimated total rows",
- RelationGetRelationName(onerel),
- bs.m, totalblocks,
- liverows, deadrows,
- numrows, *totalrows)));
Isn't it better to preserve manual ANALYZE output and only buffer sampling
messages for autoanalyze, using the existing message text?
Removing this also loses DEBUG2 sampling output when no completion
log is emitted. Could we report the buffered details at DEBUG2 when
analysis finishes in that case, without enabling resource usage
tracking? If they are included in the normal LOG message, there
should be no separate DEBUG2 message.
+ AnalyzeSamplingStats sampling_stats = {0};
+ List *sampling_stats_list = NIL;
A local StringInfo buffer passed to the core sampling functions
seems simpler than a stats structure and a per-child list. Each
sampled regular table could append its existing message to it.
+typedef struct AnalyzeSamplingStats
+{
+ Oid relid; /* relation OID */
With that approach, the new public structure and its typedefs.list
entry are unnecessary.
+ child_sampling_stats = (AnalyzeSamplingStats *)
+ palloc(sizeof(AnalyzeSamplingStats));
This allocates logging data even when it will not be used.
Could we allocate the buffer only when completion logging is
enabled or DEBUG2 output is requested? Otherwise, no sampling
messages need to be collected or emitted by autoanalyze.
Regarding FDWs, I'd prefer to leave their logging unchanged.
Autovacuum does not directly analyze foreign tables, although it
can reach them through inheritance. For now, I think it is fine
to keep the messages emitted by FDWs during sampling, rather
than include their details in the completion log.
I've attached an updated patch addressing these points, including
updates to the function comments and commit message.
Thought?
Regards,
--
Fujii Masao
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Add-sampling-statistics-to-autoanalyze-log-output.patch | application/octet-stream | 11.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ashutosh Bapat | 2026-12-04 14:57:47 | Re: Better shared data structure management and resizable shared data structures |
| Previous Message | vignesh C | 2026-12-04 14:16:58 | Re: Show the conflict log table in \dRs+ output |