drizzle-team / drizzle-team/drizzle-orm
[FEATURE]:Allow Prepared Statements to be Used Across Transactions
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Hi Drizzle ORM team,
First of all, thank you for the excellent work on this ORM! It's been a great tool for managing database interactions in our projects.
Request:
I would like to request the ability to use prepared statements that are created outside of a transaction context within transactions. Currently, it seems that if a prepared statement is created outside of a transaction, it cannot be correctly utilized within a transaction. This limitation can lead to inefficiencies when the same query needs to be prepared and executed multiple times across different transactions.
Use Case:
In scenarios where a specific SQL query, such as a DELETE or INSERT, is executed frequently within transactions, it would be beneficial to prepare the statement once and then reuse it across multiple transactions. This would improve performance by reducing the overhead associated with preparing the same statement repeatedly.
Current Workaround:
As a workaround, we currently have to prepare the statement within each transaction, which somewhat negates the performance benefits of using prepared statements, especially in high-frequency transaction scenarios.
Proposed Solution:
It would be great if prepared statements could be decoupled from the transaction context, allowing them to be reused across different transactions. This could be achieved by internally binding the prepared statement to the transaction context at the time of execution, rather than at the time of preparation.
Contributor guide
Assessment
This issue has not been assessed yet.