From: | Luc Vlaming <luc(at)swarm64(dot)com> |
---|---|
To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | Paul Guo <guopa(at)vmware(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Simon Riggs <simon(at)2ndquadrant(dot)com> |
Subject: | Re: Multi Inserts in CREATE TABLE AS - revived patch |
Date: | 2020-11-25 08:41:02 |
Message-ID: | 6ead4ebe-257f-3a68-bef2-7e7af6d0b824@swarm64.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 23-11-2020 11:23, Bharath Rupireddy wrote:
> On Mon, Nov 23, 2020 at 3:26 PM Heikki Linnakangas <hlinnaka(at)iki(dot)fi> 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 that and am about to post a new patch. Anyways,
> thanks for the rebased v3 patch. Attaching here v3 again for
> visibility.
>
> With Regards,
> Bharath Rupireddy.
> EnterpriseDB: http://www.enterprisedb.com
>
Hi,
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).
I'm wondering about the use of the GetTupleSize function. As far as I
understand the idea is to limit the amount of buffered data, presumably
to not write too much data at once for intorel_flush_multi_insert.
If I understood correctly how it all works, the table slot can however
be of different type than the source slot, which makes that the call to
CopySlot() potentially stores a different amount of data than computed
by GetTupleSize(). Not sure if this is a big problem as an estimation
might be good enough?
Some other solutions/implementations would be:
- compute the size after doing CopySlot. Maybe the relation never wants
a virtual tuple and then you can also simplify GetTupleSize?
- after CopySlot ask for the memory consumed in the slot using
MemoryContextMemAllocated.
Some small things to maybe change are:
===========
+ if (myState->mi_slots[myState->mi_slots_num] == NULL)
+ {
+ batchslot = table_slot_create(myState->rel, NULL);
+ myState->mi_slots[myState->mi_slots_num] = batchslot;
+ }
+ else
+ batchslot = myState->mi_slots[myState->mi_slots_num];
Alternative:
+ if (myState->mi_slots[myState->mi_slots_num] == NULL)
+ myState->mi_slots[myState->mi_slots_num] =
table_slot_create(myState->rel, NULL);
+ batchslot = myState->mi_slots[myState->mi_slots_num];
==============
+ sz = att_align_nominal(sz, att->attalign);
This could be moved out of the if statement?
==============
Regards,
Luc
Swarm64
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Smith | 2020-11-25 08:56:24 | Re: Enumize logical replication message actions |
Previous Message | Peter Eisentraut | 2020-11-25 08:29:55 | Re: Prevent printing "next step instructions" in initdb and pg_upgrade |