Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-12 Thread Amit Kapila
On Sun, Apr 12, 2020 at 4:03 AM Justin Pryzby wrote: > > On Sat, Mar 28, 2020 at 04:17:21PM +0100, Julien Rouhaud wrote: > > On Sat, Mar 28, 2020 at 02:38:27PM +0100, Julien Rouhaud wrote: > > > On Sat, Mar 28, 2020 at 04:14:04PM +0530, Amit Kapila wrote: > > > > > > > > I see some basic problems

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-12 Thread Julien Rouhaud
Le dim. 12 avr. 2020 à 00:33, Justin Pryzby a écrit : > On Sat, Mar 28, 2020 at 04:17:21PM +0100, Julien Rouhaud wrote: > > > > Just to be sure I did a quick test with pg_stat_statements behavior using > > parallel/non-parallel CREATE INDEX and VACUUM, and unsurprisingly buffer > usage > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-11 Thread Justin Pryzby
On Sat, Mar 28, 2020 at 04:17:21PM +0100, Julien Rouhaud wrote: > On Sat, Mar 28, 2020 at 02:38:27PM +0100, Julien Rouhaud wrote: > > On Sat, Mar 28, 2020 at 04:14:04PM +0530, Amit Kapila wrote: > > > > > > I see some basic problems with the patch. The way it tries to compute > > > WAL usage for

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-08 Thread Amit Kapila
On Wed, Apr 8, 2020 at 1:49 PM Masahiko Sawada wrote: > > On Wed, 8 Apr 2020 at 16:04, Amit Kapila wrote: > > > > On Wed, Apr 8, 2020 at 11:53 AM Masahiko Sawada > > wrote: > > > > > > On Wed, 8 Apr 2020 at 14:44, Amit Kapila wrote: > > > > > > > > > > > > Thanks for the investigation. I

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-08 Thread Masahiko Sawada
On Wed, 8 Apr 2020 at 16:04, Amit Kapila wrote: > > On Wed, Apr 8, 2020 at 11:53 AM Masahiko Sawada > wrote: > > > > On Wed, 8 Apr 2020 at 14:44, Amit Kapila wrote: > > > > > > > > > Thanks for the investigation. I don't see we can do anything special > > > about this. In an ideal world, this

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-08 Thread Julien Rouhaud
On Wed, Apr 8, 2020 at 8:23 AM Masahiko Sawada wrote: > > On Wed, 8 Apr 2020 at 14:44, Amit Kapila wrote: > > > > On Tue, Apr 7, 2020 at 5:17 PM Masahiko Sawada > > wrote: > > > > > > On Tue, 7 Apr 2020 at 18:29, Masahiko Sawada > > > wrote: > > > > > > > > On Tue, 7 Apr 2020 at 17:42, Amit

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-08 Thread Amit Kapila
On Wed, Apr 8, 2020 at 11:53 AM Masahiko Sawada wrote: > > On Wed, 8 Apr 2020 at 14:44, Amit Kapila wrote: > > > > > > Thanks for the investigation. I don't see we can do anything special > > about this. In an ideal world, this should be done once and not for > > each worker but I guess it

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-08 Thread Masahiko Sawada
On Wed, 8 Apr 2020 at 14:44, Amit Kapila wrote: > > On Tue, Apr 7, 2020 at 5:17 PM Masahiko Sawada > wrote: > > > > On Tue, 7 Apr 2020 at 18:29, Masahiko Sawada > > wrote: > > > > > > On Tue, 7 Apr 2020 at 17:42, Amit Kapila wrote: > > > > > > > > On Tue, Apr 7, 2020 at 1:30 PM Masahiko Sawada

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-07 Thread Amit Kapila
On Tue, Apr 7, 2020 at 5:17 PM Masahiko Sawada wrote: > > On Tue, 7 Apr 2020 at 18:29, Masahiko Sawada > wrote: > > > > On Tue, 7 Apr 2020 at 17:42, Amit Kapila wrote: > > > > > > On Tue, Apr 7, 2020 at 1:30 PM Masahiko Sawada > > > wrote: > > > > > > > > Buffer usage statistics seem correct.

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-07 Thread Masahiko Sawada
On Tue, 7 Apr 2020 at 18:29, Masahiko Sawada wrote: > > On Tue, 7 Apr 2020 at 17:42, Amit Kapila wrote: > > > > On Tue, Apr 7, 2020 at 1:30 PM Masahiko Sawada > > wrote: > > > > > > Buffer usage statistics seem correct. The small differences would be > > > catalog lookups Peter mentioned. > > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-07 Thread Masahiko Sawada
On Tue, 7 Apr 2020 at 17:42, Amit Kapila wrote: > > On Tue, Apr 7, 2020 at 1:30 PM Masahiko Sawada > wrote: > > > > Buffer usage statistics seem correct. The small differences would be > > catalog lookups Peter mentioned. > > > > Agreed, but can you check which part of code does that lookup? I

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-07 Thread Amit Kapila
On Tue, Apr 7, 2020 at 1:30 PM Masahiko Sawada wrote: > > Buffer usage statistics seem correct. The small differences would be > catalog lookups Peter mentioned. > Agreed, but can you check which part of code does that lookup? I want to see if we can avoid that from buffer usage stats or at

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-07 Thread Masahiko Sawada
On Tue, 7 Apr 2020 at 02:40, Peter Geoghegan wrote: > > On Mon, Apr 6, 2020 at 2:21 AM Amit Kapila 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,

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-06 Thread Peter Geoghegan
On Mon, Apr 6, 2020 at 2:21 AM Amit Kapila 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. -- Peter Geoghegan

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-06 Thread Amit Kapila
On Mon, Apr 6, 2020 at 12:55 PM Masahiko Sawada wrote: > > On Mon, 6 Apr 2020 at 16:16, Amit Kapila wrote: > > > > On Mon, Apr 6, 2020 at 11:19 AM Masahiko Sawada > > wrote: > > > > > > The attached patch changes to the above comment and removed the code > > > that is used to un-support only

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-06 Thread Masahiko Sawada
On Mon, 6 Apr 2020 at 16:16, Amit Kapila wrote: > > On Mon, Apr 6, 2020 at 11:19 AM Masahiko Sawada > wrote: > > > > The attached patch changes to the above comment and removed the code > > that is used to un-support only buffer usage accumulation. > > > > So, IIUC, the purpose of this patch

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-06 Thread Amit Kapila
On Mon, Apr 6, 2020 at 11:19 AM Masahiko Sawada wrote: > > The attached patch changes to the above comment and removed the code > that is used to un-support only buffer usage accumulation. > So, IIUC, the purpose of this patch will be to count the buffer usage due to the heap scan (in

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-05 Thread Masahiko Sawada
On Tue, 31 Mar 2020 at 14:13, Masahiko Sawada wrote: > > On Tue, 31 Mar 2020 at 12:58, Amit Kapila wrote: > > > > On Mon, Mar 30, 2020 at 12:31 PM Masahiko Sawada > > wrote: > > > > > > The patch for vacuum conflicts with recent changes in vacuum. So I've > > > attached rebased one. > > > > > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Dilip Kumar
On Thu, Apr 2, 2020 at 9:13 AM Dilip Kumar wrote: > > On Thu, Apr 2, 2020 at 8:34 AM Peter Geoghegan wrote: > > > > On Wed, Apr 1, 2020 at 7:52 PM Amit Kapila wrote: > > > Peter, Is this behavior expected? > > > > > > Let me summarize the situation so that it would be easier for Peter to > > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Dilip Kumar
On Thu, Apr 2, 2020 at 8:34 AM Peter Geoghegan wrote: > > On Wed, Apr 1, 2020 at 7:52 PM Amit Kapila wrote: > > Peter, Is this behavior expected? > > > > Let me summarize the situation so that it would be easier for Peter to > > comment. Julien has noticed that parallel vacuum and parallel

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Peter Geoghegan
On Wed, Apr 1, 2020 at 7:52 PM Amit Kapila wrote: > Peter, Is this behavior expected? > > Let me summarize the situation so that it would be easier for Peter to > comment. Julien has noticed that parallel vacuum and parallel create > index doesn't seem to report correct values for buffer usage

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Amit Kapila
Adding Peter G. On Wed, Apr 1, 2020 at 12:41 PM Dilip Kumar wrote: > > I have done some testing for the parallel "create index". > > postgres[99536]=# show maintenance_work_mem ; > maintenance_work_mem > -- > 1MB > (1 row) > > CREATE TABLE test (a int, b int); > INSERT INTO

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Dilip Kumar
On Wed, Apr 1, 2020 at 12:01 PM Amit Kapila wrote: > > On Wed, Apr 1, 2020 at 8:51 AM Dilip Kumar wrote: > > > > > Agreed. I've attached the updated patch. > > > > > > Thank you for testing, Dilip! > > > > Thanks! One hunk is failing on the latest head. And, I have rebased > > the patch for my

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Dilip Kumar
On Wed, Apr 1, 2020 at 8:51 AM Dilip Kumar wrote: > > On Wed, Apr 1, 2020 at 8:26 AM Masahiko Sawada > wrote: > > > > On Wed, 1 Apr 2020 at 11:46, Amit Kapila wrote: > > > > > > On Tue, Mar 31, 2020 at 7:32 PM Dilip Kumar wrote: > > > > > > > > While testing I have found one issue. Basically,

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-04-01 Thread Amit Kapila
On Wed, Apr 1, 2020 at 8:51 AM Dilip Kumar wrote: > > > Agreed. I've attached the updated patch. > > > > Thank you for testing, Dilip! > > Thanks! One hunk is failing on the latest head. And, I have rebased > the patch for my testing so posting the same. I have done some more > testing to test

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Dilip Kumar
On Wed, Apr 1, 2020 at 8:26 AM Masahiko Sawada wrote: > > On Wed, 1 Apr 2020 at 11:46, Amit Kapila wrote: > > > > On Tue, Mar 31, 2020 at 7:32 PM Dilip Kumar wrote: > > > > > > While testing I have found one issue. Basically, during a parallel > > > vacuum, it was showing more number of > > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Masahiko Sawada
On Wed, 1 Apr 2020 at 11:46, Amit Kapila wrote: > > On Tue, Mar 31, 2020 at 7:32 PM Dilip Kumar wrote: > > > > While testing I have found one issue. Basically, during a parallel > > vacuum, it was showing more number of > > shared_blk_hits+shared_blks_read. After, some investigation, I found >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Dilip Kumar
On Wed, Apr 1, 2020 at 8:16 AM Amit Kapila wrote: > > On Tue, Mar 31, 2020 at 7:32 PM Dilip Kumar wrote: > > > > While testing I have found one issue. Basically, during a parallel > > vacuum, it was showing more number of > > shared_blk_hits+shared_blks_read. After, some investigation, I found

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Amit Kapila
On Tue, Mar 31, 2020 at 7:32 PM Dilip Kumar wrote: > > While testing I have found one issue. Basically, during a parallel > vacuum, it was showing more number of > shared_blk_hits+shared_blks_read. After, some investigation, I found > that during the cleanup phase nworkers are -1, and because

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Dilip Kumar
On Tue, Mar 31, 2020 at 12:20 PM Dilip Kumar wrote: > > On Tue, Mar 31, 2020 at 10:44 AM Masahiko Sawada > wrote: > > > > On Tue, 31 Mar 2020 at 12:58, Amit Kapila wrote: > > > > > > On Mon, Mar 30, 2020 at 12:31 PM Masahiko Sawada > > > wrote: > > > > > > > > The patch for vacuum conflicts

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-31 Thread Dilip Kumar
On Tue, Mar 31, 2020 at 10:44 AM Masahiko Sawada wrote: > > On Tue, 31 Mar 2020 at 12:58, Amit Kapila wrote: > > > > On Mon, Mar 30, 2020 at 12:31 PM Masahiko Sawada > > wrote: > > > > > > The patch for vacuum conflicts with recent changes in vacuum. So I've > > > attached rebased one. > > > >

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-30 Thread Masahiko Sawada
On Tue, 31 Mar 2020 at 12:58, Amit Kapila wrote: > > On Mon, Mar 30, 2020 at 12:31 PM Masahiko Sawada > wrote: > > > > The patch for vacuum conflicts with recent changes in vacuum. So I've > > attached rebased one. > > > > + /* > + * Next, accumulate buffer usage. (This must wait for the

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-30 Thread Amit Kapila
On Mon, Mar 30, 2020 at 12:31 PM Masahiko Sawada wrote: > > The patch for vacuum conflicts with recent changes in vacuum. So I've > attached rebased one. > + /* + * Next, accumulate buffer usage. (This must wait for the workers to + * finish, or we might get incomplete data.) + */ + for (i = 0;

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-30 Thread Julien Rouhaud
On Mon, Mar 30, 2020 at 04:01:18PM +0900, Masahiko Sawada wrote: > On Mon, 30 Mar 2020 at 15:46, Masahiko Sawada > wrote: > > > > On Sun, 29 Mar 2020 at 20:44, Masahiko Sawada > > wrote: > > > > > > > > > I think we need to change parallel maintenance commands so that they > > > > > > report

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-30 Thread Masahiko Sawada
On Mon, 30 Mar 2020 at 15:46, Masahiko Sawada wrote: > > On Sun, 29 Mar 2020 at 20:44, Masahiko Sawada > wrote: > > > > On Sun, 29 Mar 2020 at 20:15, Amit Kapila wrote: > > > > > > On Sun, Mar 29, 2020 at 1:44 PM Julien Rouhaud wrote: > > > > > > > > On Sun, Mar 29, 2020 at 9:52 AM Masahiko

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-30 Thread Masahiko Sawada
On Sun, 29 Mar 2020 at 20:44, Masahiko Sawada wrote: > > On Sun, 29 Mar 2020 at 20:15, Amit Kapila wrote: > > > > On Sun, Mar 29, 2020 at 1:44 PM Julien Rouhaud wrote: > > > > > > On Sun, Mar 29, 2020 at 9:52 AM Masahiko Sawada > > > wrote: > > > > > > > > I've run vacuum with/without parallel

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-29 Thread Masahiko Sawada
On Sun, 29 Mar 2020 at 20:15, Amit Kapila wrote: > > On Sun, Mar 29, 2020 at 1:44 PM Julien Rouhaud wrote: > > > > On Sun, Mar 29, 2020 at 9:52 AM Masahiko Sawada > > wrote: > > > > > > I've run vacuum with/without parallel workers on the table having 5 > > > indexes. The vacuum reads all

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-29 Thread Amit Kapila
On Sun, Mar 29, 2020 at 1:44 PM Julien Rouhaud wrote: > > On Sun, Mar 29, 2020 at 9:52 AM Masahiko Sawada > wrote: > > > > I've run vacuum with/without parallel workers on the table having 5 > > indexes. The vacuum reads all blocks of table and indexes. > > > > * VACUUM command with no parallel

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-29 Thread Julien Rouhaud
On Sun, Mar 29, 2020 at 9:52 AM Masahiko Sawada wrote: > > On Sun, 29 Mar 2020 at 15:19, Masahiko Sawada > wrote: > > > > On Sun, 29 Mar 2020 at 14:23, Amit Kapila wrote: > > > > > > On Sat, Mar 28, 2020 at 8:47 PM Julien Rouhaud wrote: > > > > > > > > On Sat, Mar 28, 2020 at 02:38:27PM +0100,

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-29 Thread Masahiko Sawada
On Sun, 29 Mar 2020 at 15:19, Masahiko Sawada wrote: > > On Sun, 29 Mar 2020 at 14:23, Amit Kapila wrote: > > > > On Sat, Mar 28, 2020 at 8:47 PM Julien Rouhaud wrote: > > > > > > On Sat, Mar 28, 2020 at 02:38:27PM +0100, Julien Rouhaud wrote: > > > > On Sat, Mar 28, 2020 at 04:14:04PM +0530,

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-29 Thread Masahiko Sawada
On Sun, 29 Mar 2020 at 14:23, Amit Kapila wrote: > > On Sat, Mar 28, 2020 at 8:47 PM Julien Rouhaud wrote: > > > > On Sat, Mar 28, 2020 at 02:38:27PM +0100, Julien Rouhaud wrote: > > > On Sat, Mar 28, 2020 at 04:14:04PM +0530, Amit Kapila wrote: > > > > > > > > I see some basic problems with the

Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)

2020-03-28 Thread Amit Kapila
On Sat, Mar 28, 2020 at 8:47 PM Julien Rouhaud wrote: > > On Sat, Mar 28, 2020 at 02:38:27PM +0100, Julien Rouhaud wrote: > > On Sat, Mar 28, 2020 at 04:14:04PM +0530, Amit Kapila wrote: > > > > > > I see some basic problems with the patch. The way it tries to compute > > > WAL usage for