Обсуждение: Standardize relation name formatting in ANALYZE messages
Hi Hacker,
While testing patch [1], I noticed that ANALYZE VERBOSE currently reports the same relation name in inconsistent forms within a single command output. For example:
```
evantest=# ANALYZE VERBOSE t_heap;
INFO: analyzing "public.t_heap"
INFO: "t_heap": scanned 173 of 173 pages, containing 10000 live rows and 0 dead rows; 10000 rows in sample, 10000 estimated total rows
INFO: finished analyzing table "evantest.public.t_heap"
avg read rate: 98.805 MB/s, avg write rate: 2.298 MB/s
buffer usage: 164 hits, 215 reads, 5 dirtied
WAL usage: 11 records, 5 full page images, 27804 bytes, 26912 full page image bytes, 0 buffers full
system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.01 s
```
Here, the three INFO lines refer to the same table using three different formats: schema.table, unqualified table name, and database.schema.table.
For readability and consistency, it seems preferable to use a single, stable formatting for relation names in ANALYZE output. This patch updates ANALYZE-related messages to consistently format relation names using quote_qualified_identifier(schema, relation), which is already the common convention used across the backend.
This is a cosmetic change only; it does not affect ANALYZE behavior. With the patch, the output now looks like:
```
evantest=# ANALYZE VERBOSE t_heap;
INFO: analyzing "public.t_heap"
INFO: "public.t_heap": scanned 173 of 173 pages, containing 10000 live rows and 0 dead rows; 10000 rows in sample, 10000 estimated total rows
INFO: finished analyzing table “public.t_heap”
.. omit rest ...
```
Вложения
Hi Chao-san,
Thanks for the patch and testing patch [1]!
This is my first review, so please forgive any oversights or mistakes on my part.
I ran some tests to verify the output and everything seems to work correctly.
I have two very minor points I'd like to comment on:
1.
A similar function, generate_qualified_relation_name(), is already defined as a static function at src/backend/utils/adt/ruleutils.c:13246 and is used in several places within that file.
One option to consider: to avoid duplicate implementations and ensure consistent behavior, this function could be exported via ruleutils.h and called from analyze.c by passing RelationGetRelid(rel). However, this would require changes to ruleutils.h, so please consider whether that is appropriate for the scope of this patch.
Thanks for the patch and testing patch [1]!
This is my first review, so please forgive any oversights or mistakes on my part.
I ran some tests to verify the output and everything seems to work correctly.
I have two very minor points I'd like to comment on:
1.
A similar function, generate_qualified_relation_name(), is already defined as a static function at src/backend/utils/adt/ruleutils.c:13246 and is used in several places within that file.
One option to consider: to avoid duplicate implementations and ensure consistent behavior, this function could be exported via ruleutils.h and called from analyze.c by passing RelationGetRelid(rel). However, this would require changes to ruleutils.h, so please consider whether that is appropriate for the scope of this patch.
2.
As you mentioned, the existing log output includes the database name in the "finished" message.
Including the database name might provide slightly more information.
Current ANALYZE VERBOSE log
```
postgres=# ANALYZE VERBOSE parent_schema.sales;
INFO: analyzing "parent_schema.sales" inheritance tree
INFO: "sales_2024": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "sales_2025": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: finished analyzing table "postgres.parent_schema.sales"
avg read rate: 3.906 MB/s, avg write rate: 0.000 MB/s
buffer usage: 155 hits, 2 reads, 0 dirtied
WAL usage: 9 records, 0 full page images, 1388 bytes, 0 full page image bytes, 0 buffers full
system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
```
Current AUTOANALYZE log
```
2026-01-12 23:53:59.863 JST [28190] LOG: automatic analyze of table "postgres.public.parent_table"
avg read rate: 0.000 MB/s, avg write rate: 0.000 MB/s
buffer usage: 113 hits, 0 reads, 0 dirtied
WAL usage: 4 records, 0 full page images, 2282 bytes, 0 full page image bytes, 0 buffers full
system usage: CPU: user: 0.01 s, system: 0.00 s, elapsed: 0.01 s
```
Regards,
Tatsuya Kawata
As you mentioned, the existing log output includes the database name in the "finished" message.
Including the database name might provide slightly more information.
Current ANALYZE VERBOSE log
```
postgres=# ANALYZE VERBOSE parent_schema.sales;
INFO: analyzing "parent_schema.sales" inheritance tree
INFO: "sales_2024": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: "sales_2025": scanned 1 of 1 pages, containing 2 live rows and 0 dead rows; 2 rows in sample, 2 estimated total rows
INFO: finished analyzing table "postgres.parent_schema.sales"
avg read rate: 3.906 MB/s, avg write rate: 0.000 MB/s
buffer usage: 155 hits, 2 reads, 0 dirtied
WAL usage: 9 records, 0 full page images, 1388 bytes, 0 full page image bytes, 0 buffers full
system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
```
Current AUTOANALYZE log
```
2026-01-12 23:53:59.863 JST [28190] LOG: automatic analyze of table "postgres.public.parent_table"
avg read rate: 0.000 MB/s, avg write rate: 0.000 MB/s
buffer usage: 113 hits, 0 reads, 0 dirtied
WAL usage: 4 records, 0 full page images, 2282 bytes, 0 full page image bytes, 0 buffers full
system usage: CPU: user: 0.01 s, system: 0.00 s, elapsed: 0.01 s
```
Regards,
Tatsuya Kawata