Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-12-30 Thread Simon Riggs
On Mon, 16 Nov 2020 at 15:32, Bharath Rupireddy wrote: > > On Mon, Nov 16, 2020 at 8:02 PM Paul Guo wrote: > > > > > On Nov 13, 2020, at 7:21 PM, Bharath Rupireddy > > > wrote: > > > > > > On Tue, Nov 10, 2020 at 3:47 PM Paul Guo wrote: > > >> > > >> Thanks for doing this. There might be

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-12-03 Thread Bharath Rupireddy
On Thu, Dec 3, 2020 at 1:38 PM Dilip Kumar wrote: > > On Mon, Nov 30, 2020 at 10:49 AM Bharath Rupireddy > wrote: > > > > Currently, required logic for multi inserts (such as buffer slots > > allocation, flushing, tuple size calculation to decide when to flush, > > cleanup and so on) is being

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-12-03 Thread Dilip Kumar
On Mon, Nov 30, 2020 at 10:49 AM Bharath Rupireddy wrote: > > Hi, > > Currently, required logic for multi inserts (such as buffer slots allocation, > flushing, tuple size calculation to decide when to flush, cleanup and so on) > is being handled outside of the existing tableam APIs. And there

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-29 Thread Bharath Rupireddy
Hi, Currently, required logic for multi inserts (such as buffer slots allocation, flushing, tuple size calculation to decide when to flush, cleanup and so on) is being handled outside of the existing tableam APIs. And there are a good number of cases where multi inserts can be used, such as for

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Bharath Rupireddy
On Fri, Nov 27, 2020 at 12:22 PM Luc Vlaming wrote: > > > > > I wonder, how can the do_multi_insert() API decide on when to flush, I > > mean, based on the number of pages to flush? Do we need to pass the > > maximum number of pages the buffered tuples can occupy and track the > > pages currently

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Luc Vlaming
On 26-11-2020 14:45, Bharath Rupireddy wrote: On Thu, Nov 26, 2020 at 5:34 PM Luc Vlaming wrote: On 26-11-2020 12:36, Bharath Rupireddy wrote: Few things: IIUC Andres mentioned similar kinds of APIs earlier in [1]. [1] -

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Bharath Rupireddy
On Thu, Nov 26, 2020 at 5:34 PM Luc Vlaming wrote: > > On 26-11-2020 12:36, Bharath Rupireddy wrote: > > Few things: > > > > IIUC Andres mentioned similar kinds of APIs earlier in [1]. > > > > [1] - > > https://www.postgresql.org/message-id/20200924024128.kyk3r5g7dnu3fxxx%40alap3.anarazel.de > >

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Luc Vlaming
On 26-11-2020 12:36, Bharath Rupireddy wrote: Few things: IIUC Andres mentioned similar kinds of APIs earlier in [1]. [1] - https://www.postgresql.org/message-id/20200924024128.kyk3r5g7dnu3fxxx%40alap3.anarazel.de

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Bharath Rupireddy
Few things: IIUC Andres mentioned similar kinds of APIs earlier in [1]. [1] - https://www.postgresql.org/message-id/20200924024128.kyk3r5g7dnu3fxxx%40alap3.anarazel.de I would like to add some more info to one of the API: typedef struct MultiInsertStateData { MemoryContext

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-26 Thread Bharath Rupireddy
On Thu, Nov 26, 2020 at 12:25 PM Luc Vlaming wrote: > > What I'm wondering about is the reason for wanting a cap on data volume. > When doing some local (highly concurrent) ingest speed tests a few weeks > ago it seemed to mostly matter how many pages were being written and the > resulting

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-25 Thread Luc Vlaming
On 26-11-2020 07:31, Bharath Rupireddy wrote: On Thu, Nov 26, 2020 at 9:55 AM Michael Paquier wrote: +inline Size +GetTupleSize(TupleTableSlot *slot, Size maxsize) +{ + Size sz = 0; + HeapTuple tuple = NULL; + + if (TTS_IS_HEAPTUPLE(slot)) + tuple = ((HeapTupleTableSlot *)

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-25 Thread Bharath Rupireddy
On Thu, Nov 26, 2020 at 9:55 AM Michael Paquier wrote: > > +inline Size > +GetTupleSize(TupleTableSlot *slot, Size maxsize) > +{ > + Size sz = 0; > + HeapTuple tuple = NULL; > + > + if (TTS_IS_HEAPTUPLE(slot)) > + tuple = ((HeapTupleTableSlot *) slot)->tuple; > + else

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-25 Thread Michael Paquier
On Thu, Nov 26, 2020 at 07:24:01AM +0530, Bharath Rupireddy wrote: > Yeah. The tuple size may change after ExecCopySlot(). For instance, create > table t2 as select a1 from t1; where t1 has two integer columns a1, b1. I'm > creating t2 with single column a1 from t1 which makes the source slot >

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-25 Thread Bharath Rupireddy
On Wed, Nov 25, 2020 at 2:11 PM Luc Vlaming wrote: > > Thanks for reviving the patch! I did unfortunately have to shift my > priorities somewhat and did not find much time to work on open source > things the last week(s). > Thanks for the comments. > > I'm wondering about the use of the

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-25 Thread Luc Vlaming
On 23-11-2020 11:23, Bharath Rupireddy wrote: On Mon, Nov 23, 2020 at 3:26 PM Heikki Linnakangas wrote: On 23/11/2020 11:15, Bharath Rupireddy wrote: Attaching v2 patch, rebased on the latest master 17958972. I just broke this again with commit c532d15ddd to split up copy.c. Here's another

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-23 Thread Bharath Rupireddy
On Mon, Nov 23, 2020 at 3:26 PM Heikki Linnakangas wrote: > > On 23/11/2020 11:15, Bharath Rupireddy wrote: > > Attaching v2 patch, rebased on the latest master 17958972. > > I just broke this again with commit c532d15ddd to split up copy.c. > Here's another rebased version. > Thanks! I noticed

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-23 Thread Heikki Linnakangas
On 23/11/2020 11:15, Bharath Rupireddy wrote: Attaching v2 patch, rebased on the latest master 17958972. I just broke this again with commit c532d15ddd to split up copy.c. Here's another rebased version. - Heikki >From dca55175c590914f6a802ec3d36e20db55a3e3c7 Mon Sep 17 00:00:00 2001 From:

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-23 Thread Bharath Rupireddy
Attaching v2 patch, rebased on the latest master 17958972. With Regards, Bharath Rupireddy. EnterpriseDB: http://www.enterprisedb.com v2-0001-Multi-Inserts-in-Create-Table-As.patch Description: Binary data

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-16 Thread Bharath Rupireddy
On Mon, Nov 16, 2020 at 8:02 PM Paul Guo wrote: > > > On Nov 13, 2020, at 7:21 PM, Bharath Rupireddy > > wrote: > > > > On Tue, Nov 10, 2020 at 3:47 PM Paul Guo wrote: > >> > >> Thanks for doing this. There might be another solution - use raw insert > >> interfaces (i.e. raw_heap_insert()). >

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-16 Thread Paul Guo
> On Nov 13, 2020, at 7:21 PM, Bharath Rupireddy > wrote: > > On Tue, Nov 10, 2020 at 3:47 PM Paul Guo wrote: >> >> Thanks for doing this. There might be another solution - use raw insert >> interfaces (i.e. raw_heap_insert()). >> Attached is the test (not formal) patch that verifies this

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-13 Thread Bharath Rupireddy
On Tue, Nov 10, 2020 at 3:47 PM Paul Guo wrote: > > Thanks for doing this. There might be another solution - use raw insert > interfaces (i.e. raw_heap_insert()). > Attached is the test (not formal) patch that verifies this idea. > raw_heap_insert() writes the page into the > table files

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-10 Thread Justin Pryzby
On Tue, Nov 10, 2020 at 10:17:15AM +, Paul Guo wrote: > Raw insert could be used on CTAS & Create MatView. For Refresh MatView the > code is a bit > different. I did not spend more time on this so not sure raw insert could be > used for that. > > But I think the previous multi insert work

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-10 Thread Paul Guo
> On Nov 9, 2020, at 6:41 PM, Bharath Rupireddy > wrote: > > On Tue, Nov 3, 2020 at 4:54 PM Bharath Rupireddy > wrote: >> >> If the approach followed in the patch looks okay, I can work on a separate >> patch for multi inserts in refresh materialized view cases. >> > > Hi, I'm attaching a v2

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-09 Thread Bharath Rupireddy
On Tue, Nov 3, 2020 at 4:54 PM Bharath Rupireddy wrote: > > If the approach followed in the patch looks okay, I can work on a separate > patch for multi inserts in refresh materialized view cases. > Hi, I'm attaching a v2 patch that has multi inserts for CTAS as well as REFRESH MATERIALiZED

Re: Multi Inserts in CREATE TABLE AS - revived patch

2020-11-05 Thread Bharath Rupireddy
On Tue, Nov 3, 2020 at 4:54 PM Bharath Rupireddy < bharath.rupireddyforpostg...@gmail.com> wrote: > > Use case 1- 100mn tuples, 2 integer columns, exec time in sec: > HEAD: 131.507 when the select part is not parallel, 128.832 when the select part is parallel > Patch: 98.925 when the select part

Multi Inserts in CREATE TABLE AS - revived patch

2020-11-03 Thread Bharath Rupireddy
Hi, I would like to propose an updated patch on multi/bulk inserts in CTAS [1] that tries to address the review comments that came up in [1]. One of the main review comments was to calculate/estimate the tuple size to decide on when to flush. I tried to solve this point with a new function