Skip to content

Bulk Inserts #2254

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

Open
philon123 opened this issue May 3, 2023 · 2 comments
Open

Bulk Inserts #2254

philon123 opened this issue May 3, 2023 · 2 comments

Comments

@philon123
Copy link

What do you want to change?

I would like to use queries like

INSERT INTO books(id, name) VALUES
(NULL, 'Notebook'),
(NULL, 'MacBook'),
(NULL, 'BookBook')
..;

We have support for COPY here, but it's not as flexible or as easy to use as the above syntax. Also, the above syntax allows for ON CONFLICT(id) UPDATE name = EXCLUDED.name, which is great for bulk updates / upserts.

The generated Go code should take a list of Param objects as input. I'm not quite sure how the SQL template should look, but maybe something like

-- name: BulkInsertBooks :bulk
INSERT INTO books(id, name) VALUES @bulkBookRows;

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

@philon123 philon123 added enhancement New feature or request triage New issues that hasn't been reviewed labels May 3, 2023
@kyleconroy kyleconroy added 📚 postgresql 🔧 golang and removed triage New issues that hasn't been reviewed labels Jun 6, 2023
@Jille
Copy link
Contributor

Jille commented Jun 28, 2023

I've started a Discussion about how to implement this in #2385

@adi-kmt
Copy link

adi-kmt commented Apr 8, 2024

Are we expecting this to be dynamic as well?
Because Even subqueries and conflicts don't seem to work with copy from

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

4 participants