-
Notifications
You must be signed in to change notification settings - Fork 212
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
perf: remove select before deleteMany #4249
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Weakky
force-pushed
the
perf/delete-many-redundant-select
branch
from
September 18, 2023 16:15
9da1439
to
5cdeb3b
Compare
CodSpeed Performance ReportMerging #4249 will improve performances by 5.67%Comparing Summary
Benchmarks breakdown
|
Weakky
force-pushed
the
perf/delete-many-redundant-select
branch
from
September 27, 2023 16:02
6a0058c
to
634e685
Compare
miguelff
approved these changes
Sep 29, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outstanding!
@@ -62,31 +63,45 @@ pub fn delete_many_records( | |||
model: Model, | |||
mut field: ParsedField<'_>, | |||
) -> QueryGraphBuilderResult<()> { | |||
graph.flag_transactional(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📉
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
fixes prisma/prisma#7232
fixes prisma/prisma#8239
fixes https://github.com/prisma/prisma-private/issues/217
fixes prisma/prisma#15085
fixes prisma/prisma#19950
On SQL connectors
We used to perform two
SELECT
s to fetch the ids to delete before passing these ids to the actual delete statement. This was causing several issues:SELECT
s were superfluousSELECT
. (cf issue above)This PR fixes the problem by removing the
SELECT
altogether (on a top-level deleteMany). This makes it possible to remove the transaction entirely.On MongoDB
We used to have duplicate selects before the delete. This is now fixed by passing the fetched ids down to the delete node in the graph. I'm unsure whether we can get rid of the select before the delete on Mongo because:
SQL Diff
Benchmark
Datamodel:
Dataset size: 200k users
Query:
Result: