Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative implementation for reWriteBatchedInserts #3195

Open
vlsi opened this issue Apr 8, 2024 · 1 comment
Open

Alternative implementation for reWriteBatchedInserts #3195

vlsi opened this issue Apr 8, 2024 · 1 comment

Comments

@vlsi
Copy link
Member

vlsi commented Apr 8, 2024

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:

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(?+?, ?-?)
@davecramer
Copy link
Member

This deserves some study for sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants