-
-
Notifications
You must be signed in to change notification settings - Fork 12
perf: avoid unnecessary post-mutation reads #325
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
Conversation
|
Claude finished @ymc9's task —— View job PR Review: Performance Optimization ✅I've completed my analysis of this performance optimization PR that aims to avoid unnecessary post-mutation reads. Todo Checklist:
Overall AssessmentThis is a well-implemented performance optimization that introduces intelligent decision-making about when to perform post-mutation reads. The changes are focused, coherent, and maintain backward compatibility while providing significant performance benefits. Key Changes Analysis1. New
|
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.
Pull Request Overview
This PR optimizes database operations by eliminating unnecessary post-mutation read queries. The changes analyze whether a read-back is required based on the requested fields and leverage SQL's RETURNING clause to return only the selected fields directly from mutation operations (create, update, delete, upsert). This avoids the performance overhead of separate read queries when relations or computed fields aren't needed.
Key changes:
- Introduced
mutationNeedsReadBack()analysis to determine when post-mutation reads can be skipped - Modified CRUD operations to use SQL
RETURNINGwith selected fields instead of always reading back with ID fields - Updated tests to validate the optimization works correctly with explicit
selectclauses
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime/src/client/crud/operations/base.ts | Added mutationNeedsReadBack() method and updated CRUD methods to accept fieldsToReturn parameter for RETURNING clause optimization |
| packages/runtime/src/client/crud/operations/create.ts | Modified create operations to skip read-back when possible using the new analysis |
| packages/runtime/src/client/crud/operations/update.ts | Enhanced update/upsert operations with read-back analysis and additional check for relation-only updates |
| packages/runtime/src/client/crud/operations/delete.ts | Refactored delete operations to use RETURNING clause instead of pre-delete reads |
| tests/e2e/orm/client-api/*.test.ts | Added test cases with explicit select clauses to verify optimization and updated import ordering |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
No description provided.