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

feat: refactor CreateItems(...) to batch inserts #55

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

jimlambrt
Copy link
Collaborator

I explored using pgxpool.SendBatch(...). Unfortunately, there doesn't appear to be a way to convert a gorm.DB or even an existing open sql.DB to a pgx type that can use SendBatch(...). Given that, I've fallen back to using gorm.CreateInBatches(...) which appears to be basically the same capability.

@jimlambrt jimlambrt force-pushed the jimlambrt-create-items branch 2 times, most recently from 97a971c to 8be13f4 Compare July 13, 2024 21:07
@jimlambrt jimlambrt force-pushed the jimlambrt-create-items branch from 8be13f4 to f40e362 Compare July 14, 2024 11:45
Copy link
Contributor

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive by review because I'm curious, sorry!

Copy link
Contributor

@johanbrandhorst johanbrandhorst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@jimlambrt
Copy link
Collaborator Author

Note: I'll open a future PR to refactor the handling of OnConflict into a helper func shared between Create and CreateItems

@jimlambrt jimlambrt requested a review from tmessi July 16, 2024 11:06
@jimlambrt jimlambrt force-pushed the jimlambrt-create-items branch from a52e73d to 88524c6 Compare July 16, 2024 13:05
@jimlambrt jimlambrt force-pushed the jimlambrt-create-items branch from 88524c6 to f4e2c15 Compare July 16, 2024 13:18
@jimlambrt jimlambrt merged commit 1d5f53b into main Jul 16, 2024
8 checks passed
@jimlambrt jimlambrt deleted the jimlambrt-create-items branch July 16, 2024 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants