Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Batch inserts [MOD-555] #726

Merged
merged 11 commits into from
Oct 11, 2023
Merged

Batch inserts [MOD-555] #726

merged 11 commits into from
Oct 11, 2023

Conversation

OmegaJak
Copy link
Contributor

@OmegaJak OmegaJak commented Oct 9, 2023

Convert all instances of inserts being done inside for loops that I could find (excluding doubly nested or other extra gnarly scenarios) into using batch inserts in the way currently recommended by Sqlx.

Most of the changes are pretty straightforward transformations where I replaced the for loop with an iterator statement that produces a vec per column. A few others were a bit more involved:

  • Payouts couldn't be fully transformed because it's also doing updates inside its for loop. That part hasn't changed. Now we just push to some vecs as we iterate and do a bulk insert at the end
  • Clickhouse was asking for some deduplication, so I refactored a bit to abstract commonalities between the different analytics. Because this was not the standard postgres refactor, and because it's relatively isolated, I wrote some tests around this.
  • There was some very substantial duplication in routes/v2/projects.rs around category insertion, so I refactored commonalities there.

I also didn't touch notification inserts since that change is pending in #723.

@OmegaJak OmegaJak marked this pull request as ready for review October 11, 2023 03:18
tests/files/dummy_data.sql Outdated Show resolved Hide resolved
@Geometrically Geometrically merged commit d92272f into master Oct 11, 2023
7 of 9 checks passed
@Geometrically Geometrically deleted the batch-inserts branch October 11, 2023 18:33
thesuzerain pushed a commit that referenced this pull request Dec 5, 2023
* Batch a bunch of inserts, but still more to do

* Insert many for clickhouse (+ tests)

* Batch the remaining ones except those requiring deduplication

* Risky dedups

* Bit o cleanup and formatting

* cargo sqlx prepare

* Add test around batch editing project categories

* Add struct to satisfy clippy

* Fix silly mistake that was caught by the tests!

* Leave room for growth in dummy_data
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants