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

Add ValuesListBoundStatement for handling Values list statements #234

Merged
merged 9 commits into from
Mar 8, 2024

Conversation

tristanvuong2021
Copy link
Contributor

@tristanvuong2021 tristanvuong2021 commented Mar 4, 2024

The addBinding function ends up creating a separate query for every set of bindings. See pgjdbc/r2dbc-postgresql#527. When there are a lot of inserts or updates, this severely affects performance. This PR adds a class that has a similar function as addBinding, but instead uses a values list to create a single query for multiple inserts or updates.

@wfa-reviewable
Copy link

This change is Reviewable

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 5 files at r1, all commit messages.
Reviewable status: 1 of 5 files reviewed, 2 unresolved discussions (waiting on @tristanvuong2021)


src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/StatementBuilder.kt line 23 at r2 (raw file):

/** An interface for creating a R2DBC [Statement]. */
interface StatementBuilder {

This shouldn't be called StatementBuilder, as the builder pattern involves a mutable object. What we want to pass to the transaction context is an immutable object that has already been "built".

Note that converting to a Statement is not "building".


src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/ValuesListBoundStatement.kt line 159 at r2 (raw file):

    /** Builds a [ValuesListBoundStatement] from this builder. */
    fun build(): ValuesListBoundStatement {

This should ultimately be building a BoundStatement. That is to say that we don't need a different BoundStatement type, but rather a separate DSL builder interface for building BoundStatements using value lists.

Copy link
Contributor Author

@tristanvuong2021 tristanvuong2021 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on @SanjayVas)


src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/postgres/ValuesListBoundStatement.kt line 159 at r2 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

This should ultimately be building a BoundStatement. That is to say that we don't need a different BoundStatement type, but rather a separate DSL builder interface for building BoundStatements using value lists.

Done.


src/main/kotlin/org/wfanet/measurement/common/db/r2dbc/StatementBuilder.kt line 23 at r2 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

This shouldn't be called StatementBuilder, as the builder pattern involves a mutable object. What we want to pass to the transaction context is an immutable object that has already been "built".

Note that converting to a Statement is not "building".

Done.

Copy link
Member

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r2, 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @tristanvuong2021)

Copy link
Contributor

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r2, 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @tristanvuong2021)

@tristanvuong2021 tristanvuong2021 merged commit 8dd5f40 into main Mar 8, 2024
3 checks passed
@tristanvuong2021 tristanvuong2021 deleted the tristanvuong-add-multi-value-bound-statement branch March 8, 2024 20:42
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.

None yet

4 participants