Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)
Masahiko Sawada <masahiko.sawada@2ndquadrant.com>
Commits
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Change the display of WAL usage statistics in Explain.
- 69bfaf2e1de4 13.0 landed
-
Cosmetic fixups for WAL usage work.
- ef08ca113fe3 13.0 landed
-
Allow parallel create index to accumulate buffer usage stats.
- 5c71362174eb 13.0 landed
- f179e9f01b65 11.8 landed
- 13823ad3b012 12.3 landed
-
Allow autovacuum to log WAL usage statistics.
- b7ce6de93b59 13.0 landed
-
Add the option to report WAL usage in EXPLAIN and auto_explain.
- 33e05f89c53e 13.0 landed
-
Allow pg_stat_statements to track WAL usage statistics.
- 6b466bf5f2be 13.0 landed
-
Add infrastructure to track WAL usage.
- df3b181499b4 13.0 landed
-
Include information on buffer usage during planning phase, in EXPLAIN output, take two.
- ce77abe63cfc 13.0 cited
-
Include information on buffer usage during planning phase, in EXPLAIN output.
- ed7a5095716e 13.0 cited
-
Allow parallel vacuum to accumulate buffer usage.
- 3a5e22138a8d 13.0 landed
-
Allow pg_stat_statements to track planning statistics.
- 17e03282241c 13.0 cited
Attachments
- bufferusage_create_index_v4.patch (application/octet-stream) patch v4
On Tue, 7 Apr 2020 at 02:40, Peter Geoghegan <pg@bowt.ie> wrote: > > On Mon, Apr 6, 2020 at 2:21 AM Amit Kapila <amit.kapila16@gmail.com> wrote: > > AFAIU, it uses heapam_index_build_range_scan but for writing to index, > > it doesn't use buffer manager. > > Right. It doesn't need to use the buffer manager to write to the > index, unlike (say) GIN's CREATE INDEX. Hmm, after more thoughts and testing, it seems to me that parallel btree index creation uses buffer manager while scanning the table in parallel, i.e in heapam_index_build_range_scan, which affects shared_blks_xxx in pg_stat_statements. I've some parallel create index tests with the current HEAD and with the attached patch. The table has 44248 blocks. HEAD, no workers: -[ RECORD 1 ]-------+---------- total_plan_time | 0 total_plan_time | 0 shared_blks_hit | 148 shared_blks_read | 44281 total_read_blks | 44429 shared_blks_dirtied | 44261 shared_blks_written | 24644 wal_records | 71693 wal_num_fpw | 71682 wal_bytes | 566815038 HEAD, 4 workers: -[ RECORD 1 ]-------+---------- total_plan_time | 0 total_plan_time | 0 shared_blks_hit | 160 shared_blks_read | 8892 total_read_blks | 9052 shared_blks_dirtied | 8871 shared_blks_written | 5342 wal_records | 71693 wal_num_fpw | 71682 wal_bytes | 566815038 The WAL usage statistics are good but the buffer usage statistics seem not correct. Patched, no workers: -[ RECORD 1 ]-------+---------- total_plan_time | 0 total_plan_time | 0 shared_blks_hit | 148 shared_blks_read | 44281 total_read_blks | 44429 shared_blks_dirtied | 44261 shared_blks_written | 24843 wal_records | 71693 wal_num_fpw | 71682 wal_bytes | 566815038 Patched, 4 workers: -[ RECORD 1 ]-------+---------- total_plan_time | 0 total_plan_time | 0 shared_blks_hit | 172 shared_blks_read | 44282 total_read_blks | 44454 shared_blks_dirtied | 44261 shared_blks_written | 26968 wal_records | 71693 wal_num_fpw | 71682 wal_bytes | 566815038 Buffer usage statistics seem correct. The small differences would be catalog lookups Peter mentioned. Regards, -- Masahiko Sawada http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services