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: support THEN RETURN clauses #443

Merged
merged 13 commits into from
Oct 2, 2024
Merged

feat: support THEN RETURN clauses #443

merged 13 commits into from
Oct 2, 2024

Conversation

olavloite
Copy link
Collaborator

Use THEN RETURN for returning data from INSERT/UPDATE/DELETE statements. This reduces the number of round-trips to Spanner for most use-cases. THEN RETURN clauses are not supported in BatchDml, which means that multiple DML statements that need to return values are translated to separate DML statements, instead of a BatchDmlRequest followed by N SELECT statements. Even in those cases, using THEN RETURN reduces the number of round-trips by 1.

The fact that Batch DML does not support THEN RETURN is the main reason that it is recommended to use client-side generated UUIDs for primary keys when using Entity Framework. This will allow DML statements to be batched.

Use THEN RETURN for returning data from INSERT/UPDATE/DELETE statements.
This reduces the number of round-trips to Spanner for most use-cases.
THEN RETURN clauses are not supported in BatchDml, which means that
multiple DML statements that need to return values are translated to
separate DML statements, instead of a BatchDmlRequest followed by N
SELECT statements. Even in those cases, using THEN RETURN reduces the
number of round-trips by 1.

The fact that Batch DML does not support THEN RETURN is the main reason
that it is recommended to use client-side generated UUIDs for primary
keys when using Entity Framework. This will allow DML statements to be
batched.
DML with THEN RETURN clauses are executed directly when the ExecuteDbReader
method is called. This means that they can return aborted during the
Execute call, which again means that these need to be in a retry loop.
Base automatically changed from target-entity-framework-8 to main October 2, 2024 09:35
@olavloite olavloite merged commit 58cd4e2 into main Oct 2, 2024
8 checks passed
@olavloite olavloite deleted the support-then-return branch October 2, 2024 09:43
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.

1 participant