Re: Use streaming read API in ANALYZE

2024-09-19 Thread Mats Kindahl
On Wed, Sep 18, 2024 at 5:13 AM Thomas Munro wrote: > On Sun, Sep 15, 2024 at 12:14 AM Mats Kindahl wrote: > > I used the combination of your patch and making the computation of > vacattrstats for a relation available through the API and managed to > implement something that I think does the rig

Re: Use streaming read API in ANALYZE

2024-09-17 Thread Thomas Munro
On Sun, Sep 15, 2024 at 12:14 AM Mats Kindahl wrote: > I used the combination of your patch and making the computation of > vacattrstats for a relation available through the API and managed to > implement something that I think does the right thing. (I just sampled a few > different statistics

Re: Use streaming read API in ANALYZE

2024-09-14 Thread Mats Kindahl
On Fri, Sep 13, 2024 at 10:10 AM Mats Kindahl wrote: > On Tue, Sep 10, 2024 at 6:04 AM Thomas Munro > wrote: > >> On Tue, Sep 10, 2024 at 10:27 AM Thomas Munro >> wrote: >> > Mats, what do you think about >> > this? (I haven't tried to preserve the prefetching behaviour, which >> > probably di

Re: Use streaming read API in ANALYZE

2024-09-13 Thread Mats Kindahl
On Tue, Sep 10, 2024 at 6:04 AM Thomas Munro wrote: > On Tue, Sep 10, 2024 at 10:27 AM Thomas Munro > wrote: > > Mats, what do you think about > > this? (I haven't tried to preserve the prefetching behaviour, which > > probably didn't actually too work for you in v16 anyway at a guess, > > I'm

Re: Use streaming read API in ANALYZE

2024-09-13 Thread Mats Kindahl
On Tue, Sep 10, 2024 at 12:28 AM Thomas Munro wrote: > On Tue, Sep 10, 2024 at 3:36 AM Michael Banck wrote: > > I am a bit confused about the status of this thread. Robert mentioned > > RC1, so I guess it pertains to v17 but I don't see it on the open item > > wiki list? > > Yes, v17. Alight, I

Re: Use streaming read API in ANALYZE

2024-09-10 Thread Mats Kindahl
On Thu, Sep 5, 2024 at 11:12 AM Thomas Munro wrote: > On Thu, Sep 5, 2024 at 6:45 PM Mats Kindahl wrote: > > Forgive me for asking, but I am not entirely sure why the ReadStream > struct is opaque. The usual reasons are: > > > > You want to provide an ABI to allow extensions to work with new maj

Re: Use streaming read API in ANALYZE

2024-09-09 Thread Thomas Munro
On Tue, Sep 10, 2024 at 10:27 AM Thomas Munro wrote: > Mats, what do you think about > this? (I haven't tried to preserve the prefetching behaviour, which > probably didn't actually too work for you in v16 anyway at a guess, > I'm just looking for the absolute simplest thing we can do to resolve

Re: Use streaming read API in ANALYZE

2024-09-09 Thread Thomas Munro
On Tue, Sep 10, 2024 at 3:36 AM Michael Banck wrote: > I am a bit confused about the status of this thread. Robert mentioned > RC1, so I guess it pertains to v17 but I don't see it on the open item > wiki list? Yes, v17. Alight, I'll add an item. > Does the above mean you are going to revert it

Re: Use streaming read API in ANALYZE

2024-09-09 Thread Michael Banck
v17 but I don't see it on the open item wiki list? Does the above mean you are going to revert it for v17, Thomas? And if so, what exactly? The ANALYZE changes on top of the streaming read API or something else about that API that is being discussed on this thread? I am also asking because

Re: Use streaming read API in ANALYZE

2024-09-05 Thread Thomas Munro
On Thu, Sep 5, 2024 at 6:45 PM Mats Kindahl wrote: > Forgive me for asking, but I am not entirely sure why the ReadStream struct > is opaque. The usual reasons are: > > You want to provide an ABI to allow extensions to work with new major > versions without re-compiling. Right now it is necessar

Re: Use streaming read API in ANALYZE

2024-09-04 Thread Mats Kindahl
On Thu, Sep 5, 2024 at 1:34 AM Thomas Munro wrote: > On Thu, Sep 5, 2024 at 3:36 AM Robert Haas wrote: > > On Wed, Sep 4, 2024 at 6:38 AM Thomas Munro > wrote: > > > Thanks for the explanation. I think we should revert it. IMHO it was > > > a nice clean example of a streaming transformation,

Re: Use streaming read API in ANALYZE

2024-09-04 Thread Thomas Munro
On Thu, Sep 5, 2024 at 3:36 AM Robert Haas wrote: > On Wed, Sep 4, 2024 at 6:38 AM Thomas Munro wrote: > > Thanks for the explanation. I think we should revert it. IMHO it was > > a nice clean example of a streaming transformation, but unfortunately > > it transformed an API that nobody liked i

Re: Use streaming read API in ANALYZE

2024-09-04 Thread Robert Haas
On Wed, Sep 4, 2024 at 6:38 AM Thomas Munro wrote: > Thanks for the explanation. I think we should revert it. IMHO it was > a nice clean example of a streaming transformation, but unfortunately > it transformed an API that nobody liked in the first place, and broke > some weird and wonderful wor

Re: Use streaming read API in ANALYZE

2024-09-04 Thread Thomas Munro
Thanks for the explanation. I think we should revert it. IMHO it was a nice clean example of a streaming transformation, but unfortunately it transformed an API that nobody liked in the first place, and broke some weird and wonderful workarounds. Let's try again in 18.

Re: Use streaming read API in ANALYZE

2024-08-29 Thread Mats Kindahl
On Sat, Aug 24, 2024 at 5:31 AM Thomas Munro wrote: > On Thu, Aug 22, 2024 at 7:31 PM Mats Kindahl wrote: > > The alternate version proposed by Nazir allows you to deide which > interface to use. > > Reverting the patch entirely would also solve the problem. > After digging through the code a l

Re: Use streaming read API in ANALYZE

2024-08-23 Thread Thomas Munro
On Thu, Aug 22, 2024 at 7:31 PM Mats Kindahl wrote: > The alternate version proposed by Nazir allows you to decide which interface > to use. > Reverting the patch entirely would also solve the problem. > Passing down the block sampler and the strategy to scan_begin() and move the > ReadStream se

Re: Use streaming read API in ANALYZE

2024-08-22 Thread Mats Kindahl
On Mon, May 20, 2024 at 10:46 PM Melanie Plageman wrote: > On Wed, May 15, 2024 at 2:18 PM Nazir Bilal Yavuz > wrote: > > > > On Mon, 29 Apr 2024 at 18:41, Nazir Bilal Yavuz > wrote: > > > > > > On Mon, 8 Apr 2024 at 04:21, Thomas Munro > wrote: > > > I wanted to discuss what will happen to th

Re: Use streaming read API in ANALYZE

2024-05-20 Thread Melanie Plageman
On Wed, May 15, 2024 at 2:18 PM Nazir Bilal Yavuz wrote: > > On Mon, 29 Apr 2024 at 18:41, Nazir Bilal Yavuz wrote: > > > > On Mon, 8 Apr 2024 at 04:21, Thomas Munro wrote: > > I wanted to discuss what will happen to this patch now that > > 27bc1772fc8 is reverted. I am continuing this thread bu

Re: Use streaming read API in ANALYZE

2024-05-15 Thread Nazir Bilal Yavuz
Hi, On Mon, 29 Apr 2024 at 18:41, Nazir Bilal Yavuz wrote: > > Hi, > > On Mon, 8 Apr 2024 at 04:21, Thomas Munro wrote: > > > > Pushed. Thanks Bilal and reviewers! > > I wanted to discuss what will happen to this patch now that > 27bc1772fc8 is reverted. I am continuing this thread but I can cr

Re: Use streaming read API in ANALYZE

2024-04-29 Thread Nazir Bilal Yavuz
Hi, On Mon, 8 Apr 2024 at 04:21, Thomas Munro wrote: > > Pushed. Thanks Bilal and reviewers! I wanted to discuss what will happen to this patch now that 27bc1772fc8 is reverted. I am continuing this thread but I can create another thread if you prefer so. After the revert of 27bc1772fc8, acqui

Re: Use streaming read API in ANALYZE

2024-04-16 Thread Nazir Bilal Yavuz
Hi, On Wed, 3 Apr 2024 at 22:25, Nazir Bilal Yavuz wrote: > > Hi, > > Thank you for looking into this! > > On Wed, 3 Apr 2024 at 20:17, Heikki Linnakangas wrote: > > > > On 03/04/2024 13:31, Nazir Bilal Yavuz wrote: > > > Streaming API has been committed but the committed version has a minor > >

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Thomas Munro
On Mon, Apr 8, 2024 at 10:26 AM Melanie Plageman wrote: > On Sun, Apr 07, 2024 at 03:00:00PM -0700, Andres Freund wrote: > > On 2024-04-07 16:59:26 -0400, Melanie Plageman wrote: > > > From 862b7ac81cdafcda7b525e02721da14e46265509 Mon Sep 17 00:00:00 2001 > > > From: Melanie Plageman > > > Date:

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Thomas Munro
On Mon, Apr 8, 2024 at 10:26 AM Melanie Plageman wrote: > On Sun, Apr 07, 2024 at 03:00:00PM -0700, Andres Freund wrote: > > > src/backend/commands/analyze.c | 89 ++ > > > 1 file changed, 26 insertions(+), 63 deletions(-) > > > > That's a very nice demonstration o

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Melanie Plageman
oop over blocks to sample */ > > while (BlockSampler_HasMore(&bs)) > > { > > I don't think it's good to move a lot of code *and* change how it is > structured in the same commit. Makes it much harder to actually see changes / > makes git blame harder

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Andres Freund
tructured in the same commit. Makes it much harder to actually see changes / makes git blame harder to use / etc. > From 90d115c2401567be65bcf64393a6d3b39286779e Mon Sep 17 00:00:00 2001 > From: Melanie Plageman > Date: Sun, 7 Apr 2024 15:28:32 -0400 > Subject: [PATCH v10 2/3] Use s

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Melanie Plageman
eapTupleIsSurelyDead(HeapTuple htup, struct GlobalVisState *vistest); -/* in heap/heapam_handler.c*/ -extern void heapam_scan_analyze_next_block(TableScanDesc scan, - BlockNumber blockno, - BufferAccessStrategy bstrategy); -extern bool heapam_scan_analyze_next_tuple

Re: Use streaming read API in ANALYZE

2024-04-07 Thread Melanie Plageman
id heapam_scan_analyze_next_block(TableScanDesc scan, - BlockNumber blockno, - BufferAccessStrategy bstrategy); -extern bool heapam_scan_analyze_next_tuple(TableScanDesc scan, - TransactionId OldestXmin, - double *liverows, double *deadrows, - Tu

Re: Use streaming read API in ANALYZE

2024-04-04 Thread Nazir Bilal Yavuz
gt; > From: Nazir Bilal Yavuz > > Date: Wed, 3 Apr 2024 15:14:15 +0300 > > Subject: [PATCH v6] Use streaming read API in ANALYZE > > > > ANALYZE command gets random tuples using BlockSampler algorithm. Use > > streaming reads to get these tuples by using B

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Melanie Plageman
void > *per_buffer_data) > +{ > + BlockSamplerData *bs = user_data; > + > + return BlockSampler_HasMore(bs) ? BlockSampler_Next(bs) : > InvalidBlockNumber; I don't see the point of BlockSampler_HasMore() anymore. I remov

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Nazir Bilal Yavuz
ns false One of the if cases can be bypassed by moving heapam_scan_analyze_next_block()'s code to the main loop in the acquire_sample_rows(). I implemented the third solution, here is v6. -- Regards, Nazir Bilal Yavuz Microsoft From 8d396a42186325f920d5a05e7092d8e1b66f3cdf Mon Sep 17 00:00:00 2001 From: Nazir Bila

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Nazir Bilal Yavuz
Hi Jakub, Thank you for looking into this and doing a performance analysis. On Wed, 3 Apr 2024 at 11:42, Jakub Wartak wrote: > > On Tue, Apr 2, 2024 at 9:24 AM Nazir Bilal Yavuz wrote: > [..] > > v4 is rebased on top of v14 streaming read API changes. > > Hi Nazir, so with streaming API committ

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Heikki Linnakangas
On 03/04/2024 13:31, Nazir Bilal Yavuz wrote: Streaming API has been committed but the committed version has a minor change, the read_stream_begin_relation function takes Relation instead of BufferManagerRelation now. So, here is a v5 which addresses this change. I'm getting a repeatable segfau

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Nazir Bilal Yavuz
ow. So, here is a v5 which addresses this change. -- Regards, Nazir Bilal Yavuz Microsoft From 43e2f2b32e2fdb7e1fd787b1d8595768741f4792 Mon Sep 17 00:00:00 2001 From: Nazir Bilal Yavuz Date: Wed, 3 Apr 2024 01:22:59 +0300 Subject: [PATCH v5] Use streaming read API in ANALYZE ANALYZE command gets

Re: Use streaming read API in ANALYZE

2024-04-03 Thread Jakub Wartak
On Tue, Apr 2, 2024 at 9:24 AM Nazir Bilal Yavuz wrote: [..] > v4 is rebased on top of v14 streaming read API changes. Hi Nazir, so with streaming API committed, I gave a try to this patch. With autovacuum=off and 30GB table on NVMe (with standard readahead of 256kb and ext4, Debian 12, kernel 6.

Re: Use streaming read API in ANALYZE

2024-04-02 Thread Nazir Bilal Yavuz
ced you have the old streaming read > (pgsr) naming still in a few places (including comments) -- so I would > just make sure and update everywhere when you rebase in Thomas' latest > version of the read stream API. Done. > > > From c7500cc1b9068ff0b704181442999cd8bed58658

Re: Use streaming read API in ANALYZE

2024-03-27 Thread Melanie Plageman
ed you have the old streaming read (pgsr) naming still in a few places (including comments) -- so I would just make sure and update everywhere when you rebase in Thomas' latest version of the read stream API. > From c7500cc1b9068ff0b704181442999cd8bed58658 Mon Sep 17 00:00:00 2001 > Fro

Re: Use streaming read API in ANALYZE

2024-03-26 Thread Nazir Bilal Yavuz
Hi, On Wed, 28 Feb 2024 at 14:42, Nazir Bilal Yavuz wrote: > > > The new version of the streaming read API [1] is posted. I updated the > streaming read API changes patch (0001), using the streaming read API > in ANALYZE patch (0002) remains the same. This should make it easier > to review as it

Re: Use streaming read API in ANALYZE

2024-02-28 Thread Nazir Bilal Yavuz
Hi, On Mon, 19 Feb 2024 at 18:13, Nazir Bilal Yavuz wrote: > > I worked on using the currently proposed streaming read API [1] in ANALYZE. > The patch is attached. 0001 is the not yet merged streaming read API code > changes that can be applied to the master, 0002 is the actual code. > > The bl

Use streaming read API in ANALYZE

2024-02-19 Thread Nazir Bilal Yavuz
onal_pins) /* * In contrast to LimitAdditionalPins() other backends don't play a role - * here. We can allow up to NLocBuffer pins in total. + * here. We can allow up to NLocBuffer pins in total, but it might not be + * initialized yet so read num_temp_buffers. */ - max_pins = (NLoc