Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Masahiko Sawada <sawada.mshk@gmail.com>, PostgreSQL-development
<pgsql-hackers@postgresql.org>, Andres Freund <andres@anarazel.de>, Dilip
Kumar <dilipbalaut@gmail.com>, Luc Vlaming <luc@swarm64.com>, Justin Pryzby
<pryzby@telsasoft.com>, Michael Paquier <michael@paquier.xyz>, Matthias van
de Meent <boekewurm+postgres@gmail.com>, Alexander Korotkov
<aekorotkov@gmail.com>
Date: 2024-08-26T21:18:21Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
libpq: Fix some issues in TAP tests for service files
- 2c7bd2ba507e 18.0 cited
-
Multiple revisions to the GROUP BY reordering tests
- 874d817baa16 17.0 cited
-
Explore alternative orderings of group-by pathkeys during optimization.
- 0452b461bc40 17.0 cited
On Mon, 2024-08-26 at 11:09 +0530, Bharath Rupireddy wrote: > On Wed, Jun 5, 2024 at 12:42 PM Bharath Rupireddy > <bharath.rupireddyforpostgres@gmail.com> wrote: > > > > Please find the v22 patches with the above changes. > > Please find the v23 patches after rebasing 0005 and adapting 0004 for > 9758174e2e. Thank you. 0001 API design: * Remove TableModifyState.modify_end_callback. * This patch means that we will either remove or deprecate TableAmRoutine.multi_insert and finish_bulk_insert. Are there any strong opinions about maintaining support for multi-insert, or should we just remove it outright and force any new AMs to implement the new APIs to maintain COPY performance? * Why do we need a separate "modify_flags" and "options"? Can't we just combine them into TABLE_MODIFY_* flags? Alexander, you had some work in this area as well, such b1484a3f19. I believe 0001 covers this use case in a different way: rather than giving complete responsibility to the AM to insert into the indexes, the caller provides a callback and the AM is responsible for calling it at the time the tuples are flushed. Is that right? The design has been out for a while, so unless others have suggestions, I'm considering the major design points mostly settled and I will move forward with something like 0001 (pending implementation issues). Note: I believe this API will extend naturally to updates and deletes, as well. 0001 implementation issues: * We need default implementations for AMs that don't implement the new APIs, so that the AM will still function even if it only defines the single-tuple APIs. If we need to make use of the AM's multi_insert method (I'm not sure we do), then the default methods would need to handle that as well. (I thought a previous version had these default implementations -- is there a reason they were removed?) * I am confused about how the heap implementation manages state and resets it. mistate->mem_cxt is initialized to a new memory context in heap_modify_begin, and then re-initialized to another new memory context in heap_modify_buffer_insert. Then the mistate->mem_cxt is also used as a temp context for executing heap_multi_insert, and it gets reset before calling the flush callback, which still needs the slots. * Why materialize the slot at copyfrom.c:1308 if the slot is going to be copied anyway (which also materializes it; see tts_virtual_copyslot()) at heapam.c:2710? * After correcting the memory issues, can you get updated performance numbers for COPY? Regards, Jeff Davis