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

spanner: add (Batch)?Update(WithOptions)? to Client #9583

Open
CAFxX opened this issue Mar 14, 2024 · 3 comments · Fixed by #9598
Open

spanner: add (Batch)?Update(WithOptions)? to Client #9583

CAFxX opened this issue Mar 14, 2024 · 3 comments · Fixed by #9598
Assignees
Labels
api: spanner Issues related to the Spanner API. needs more info This issue needs more information from the customer to proceed. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@CAFxX
Copy link
Contributor

CAFxX commented Mar 14, 2024

Is your feature request related to a problem? Please describe.
If a ReadWriteTransaction needs to perform only a batch of one or more update operations, it is wasteful and unneccessary to keep the transaction open for an extra roundtrip.

Describe the solution you'd like

Add the following methods to spanner.Client:

Update(ctx context.Context, stmt Statement) (rowCount int64, err error)
UpdateWithOptions(ctx context.Context, stmt Statement, opts QueryOptions) (rowCount int64, err error)
BatchUpdate(ctx context.Context, stmts []Statement) (rowCounts []int64, err error)
BatchUpdateWithOptions(ctx context.Context, stmts []Statement, opts QueryOptions) (rowCounts []int64, err error)

that would behave as a ReadWriteTransaction containing a single call to corresponding method above, so e.g.

rowCount, err := client.Update(ctx, stmt)

would behave as

var rowCount int
err := client.ReadWriteTransaction(ctx, func(ctx context.Context, rwt *spanner.ReadWriteTransaction) (err error) {
	rowCount, err = rwt.Update(ctx, stmt)
	return
})

but allowing Spanner to close the transaction as soon as the update completes, without waiting for the client to explicitly commit.

Describe alternatives you've considered
The equivalent code above works today, but is less efficient.

@CAFxX CAFxX added the triage me I really want to be triaged. label Mar 14, 2024
@product-auto-label product-auto-label bot added the api: spanner Issues related to the Spanner API. label Mar 14, 2024
@rahul2393 rahul2393 linked a pull request Mar 18, 2024 that will close this issue
1 task
@CAFxX
Copy link
Contributor Author

CAFxX commented Mar 26, 2024

@rahul2393 I suspect this was closed by mistake...

@rahul2393
Copy link
Contributor

@CAFxX reopened

@rahul2393 rahul2393 reopened this Mar 28, 2024
@rahul2393
Copy link
Contributor

@CAFxX can you please explain how having these methods will be more optimal, auto commit is not yet supported in Cloud Spanner so clients need to explicitly send the commit RPC at the end of request.

@codyoss codyoss added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. needs more info This issue needs more information from the customer to proceed. and removed triage me I really want to be triaged. labels Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the Spanner API. needs more info This issue needs more information from the customer to proceed. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants