pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: vlsi (@vlsi) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3195: Alternative implementation for reWriteBatchedInserts
Date: Mon, 08 Apr 2024 11:02:00 +0000
Message-ID: <[email protected]> (raw)

**Describe the issue**

Currently we rewrite the select to multi-values insert.
It requires multiple statements, and we use power-of-two packing to alleviate the overhead.

There is an alternative option:

```sql
insert into table(id, name, ...)
 select unnest(?), unnest(?), ...
```

Then we could bind the values as a set of arrays.

It might have the following improvements:
1) We would no longer require "power-of-two" logic
2) The query will be shorter
3) It might be faster
4) There will be no limit of "65535 binds"

TODO:
* Measure how `select unnest(?), unnest(?)` compares with `values(...), (...), (...)`
* Test if it would work with "on conflict", "merge" and so on
* Figure out if we could support `values(DEFAULT, ...)`. It might be `DEFAULT` would require adjusting the column list in the `into` clause
* Figure out if we could support expressions in `values` like `values(?+?, ?-?)`

view thread (4+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3195: Alternative implementation for reWriteBatchedInserts
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox