Skip to content

Commit

Permalink
Add pg_stat_progress_analyze: implement in 'report'.
Browse files Browse the repository at this point in the history
  • Loading branch information
lesovsky committed Mar 6, 2021
1 parent 53d22ff commit 7c53d2d
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/report/report.go
Expand Up @@ -164,6 +164,8 @@ func selectReport(opts options) string {
return "progress_cluster"
case "i":
return "progress_index"
case "a":
return "progress_analyze"
}
}

Expand Down
1 change: 1 addition & 0 deletions cmd/report/report_test.go
Expand Up @@ -51,6 +51,7 @@ func Test_selectReport(t *testing.T) {
{opts: options{showProgress: "v"}, want: "progress_vacuum"},
{opts: options{showProgress: "c"}, want: "progress_cluster"},
{opts: options{showProgress: "i"}, want: "progress_index"},
{opts: options{showProgress: "a"}, want: "progress_analyze"},
{opts: options{}, want: ""},
}

Expand Down
26 changes: 25 additions & 1 deletion report/describe.go
Expand Up @@ -217,7 +217,7 @@ Details: https://www.postgresql.org/docs/current/progress-reporting.html#VACUUM-
Details: https://www.postgresql.org/docs/current/progress-reporting.html#CLUSTER-PROGRESS-REPORTING
`

// pgStatProgressCreateIndexDescription is the detailed description of pg_stat_progress_cluster view
// pgStatProgressCreateIndexDescription is the detailed description of pg_stat_progress_create_index view
pgStatProgressCreateIndexDescription = `Statistics about progress of create index/reindex operations based on pg_stat_progress_create_index view:
column origin description
Expand All @@ -241,6 +241,30 @@ Details: https://www.postgresql.org/docs/current/progress-reporting.html#CLUSTER
Details: https://www.postgresql.org/docs/current/progress-reporting.html#CREATE-INDEX-PROGRESS-REPORTING
`

// pgStatProgressAnalyzeDescription is the detailed description of pg_stat_progress_analyze view
pgStatProgressAnalyzeDescription = `Statistics about progress of analyze operations based on pg_stat_progress_analyze view:
column origin description
- pid pid Process ID of this worker
- xact_age* xact_start Current transaction's duration if active
- datname datname Name of the database this worker is connected to
- relation relid Name of the relation which is processed by this worker
- state state Current overall state of this worker
- waiting* wait_event_type,wait_event Wait event name and type for which the worker is waiting, if any
- phase phase Current processing phase of operation
- t_size sample_blks_total Total size of the sample, in kB.
- scanned_% sample_blks_total,sample_blks_scanned Total size of scanned sample, in percent
- ext_total/done ext_stats_total,ext_stats_computed Total number of extended statistics and number of already computed statistics
- child_total/done_% child_tables_total,child_tables_done Total number of child tables and ratio of child tables already processed
- child_in_progress current_child_table_relid Name of child relation which is processed by this worker
* - extended value, based on origin and calculated using additional functions.
Details: https://www.postgresql.org/docs/current/progress-reporting.html#ANALYZE-PROGRESS-REPORTING
`

// pid xact_age datname relation state waiting phase t_size scanned_% ext_total/done child_total/done_% child_in_progress

// pgStatStatementsTimingsDescription is the detailed description of pg_stat_statements section about timing stats
pgStatStatementsTimingsDescription = `Statements timing statistics based on pg_stat_statements:
Expand Down
1 change: 1 addition & 0 deletions report/report.go
Expand Up @@ -405,6 +405,7 @@ func describeReport(w io.Writer, report string) error {
"progress_vacuum": pgStatProgressVacuumDescription,
"progress_cluster": pgStatProgressClusterDescription,
"progress_index": pgStatProgressCreateIndexDescription,
"progress_analyze": pgStatProgressAnalyzeDescription,
"statements_timings": pgStatStatementsTimingsDescription,
"statements_general": pgStatStatementsGeneralDescription,
"statements_io": pgStatStatementsIODescription,
Expand Down
5 changes: 5 additions & 0 deletions report/report_test.go
Expand Up @@ -98,6 +98,11 @@ func Test_app_doReport(t *testing.T) {
config: Config{ReportType: "progress_index", TruncLimit: 32, Rate: time.Second},
wantFile: "testdata/report_progress_index.golden",
},
{
start: "2021-01-23 15:31:00", end: "2021-01-23 15:32:00",
config: Config{ReportType: "progress_analyze", TruncLimit: 32, Rate: time.Second},
wantFile: "testdata/report_progress_analyze.golden",
},
{ // start, end times within report interval
start: "2021-01-23 15:31:26", end: "2021-01-23 15:31:27",
config: Config{ReportType: "activity", TruncLimit: 32, Rate: time.Second},
Expand Down
Binary file modified report/testdata/pgcenter.stat.golden.tar
Binary file not shown.
12 changes: 12 additions & 0 deletions report/testdata/report_progress_analyze.golden
@@ -0,0 +1,12 @@
pid xact_age datname relation state waiting phase t_size scanned_% ext_total/done child_total/done_% child_in_progress 
15:31:24 204645 00:14:44 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 56.00 0/0 0/0.00 -
15:31:25 204645 00:14:45 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 57.00 0/0 0/0.00 -
15:31:26 212982 00:01:08 pgbench 89984 active f acquiring sample rows 240000 7.00 0/0 0/0.00 -
204645 00:14:46 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 60.00 0/0 0/0.00 -
15:31:27 212982 00:01:09 pgbench 89984 active Timeout.Vacuum~ acquiring sample rows 240000 57.00 0/0 0/0.00 -
204645 00:14:47 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 61.00 0/0 0/0.00 -
15:31:28 204645 00:14:48 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 62.00 0/0 0/0.00 -
15:31:29 204645 00:14:49 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 63.00 0/0 0/0.00 -
15:31:30 204645 00:14:50 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 63.00 0/0 0/0.00 -
15:31:31 204645 00:14:51 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 64.00 0/0 0/0.00 -
15:31:32 204645 00:14:52 pgbench 89900 active IO.DataFileRead acquiring sample rows 240000 64.00 0/0 0/0.00 -

0 comments on commit 7c53d2d

Please sign in to comment.