Improving DB Querying #2350
krrishdholakia
started this conversation in
General
Replies: 1 comment
-
cc: @Manouchehri |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Ensure data types are the most efficient for their purpose, reducing storage and improving query performance.
Implement indexes on columns frequently used in queries to speed up read operations.
Define clear foreign key relationships for data integrity and efficient joins.
Set sensible defaults and constraints to simplify logic and reduce null checks.
Balance between normalization for data integrity and denormalization for read performance. Use denormalization cautiously, when read performance is a priority over write performance.
Query Optimization
Leverage Prisma's capabilities for efficient querying, like selective field querying, to minimize data transfer.
Batching and Transactions
Use Prisma's support for transactions and batching to reduce the number of round-trips to the database for multiple operations.
For Json fields, ensure that the flexibility they provide is necessary, as querying and indexing are less efficient than scalar types.
Example of Implementing Recommendations:
Before:
After implementing optimizations:
Further improvements
Move to using
prisma migrate
instead ofprisma db push
. This will speed up the proxy startup time, as prisma can check for any schema changes locally.Open Questions
Beta Was this translation helpful? Give feedback.
All reactions