Support for manually managing prepared statements #24171
Labels
kind/feature
A request for a new feature.
team/client
Issue for team Client.
topic: client api
topic: extend-client
Extending the Prisma Client
Problem
Currently, Prisma ORM prepares queries dynamically each time a CRUD operation is performed on a table. This can result in unnecessary overhead, while in complex queries e.g. nesting relations and selecting fields, it can significantly reduce the performance. especially when the same query is executed multiple times with different values it does not make sense to build the query on each execution when only a few fixed parameters are changed.
Comparison with Existing Feature:
Drizzle ORM: drizzle-orm provides support for prepared statement which can be used to prebuild queries to use later with dynamic parameters. below snipped from the official docs.
Similar to prisma.$queryRaw, prepared statements offer the advantage of dynamic query execution. However, they provide 100% type safety just like prisma's ordinary table methods.
Suggested solution
Introduce support for prepared statements in Prisma ORM. Prepared statements act as pre-defined query templates that can be constructed once and reused with varying parameters. This approach can improve query performance and simplify code complexity.
For the above feature I expect a similar FluentApi to build a prepared statement or alternatively expected syntax can be :
The text was updated successfully, but these errors were encountered: