Why not every query is a prepared statement by default? #2030
-
Hi there! I've been reading a lot about performance on different ORMs. I came across this official benchmark and I see that drizzle with prepared statements is one of the most performants. Why not every query in drizzle is a prepared statement? What would be the downsides? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Drizzle won't handle anything implicitly for you, so you should always specify it yourself. There are cases when prepared statements are both beneficial and detrimental, depending on the environment and architecture you are using. It's generally advantageous with Drizzle as long as the query isn't built on every execution, but it may be disadvantageous (in some cases) at the database level. For example, prepared statements on AWS RDS can exhaust your connection pooler. Additionally, prepared statements require some database memory to store cached queries, which may pose a problem for you (though not always) |
Beta Was this translation helpful? Give feedback.
Drizzle won't handle anything implicitly for you, so you should always specify it yourself. There are cases when prepared statements are both beneficial and detrimental, depending on the environment and architecture you are using. It's generally advantageous with Drizzle as long as the query isn't built on every execution, but it may be disadvantageous (in some cases) at the database level.
For example, prepared statements on AWS RDS can exhaust your connection pooler. Additionally, prepared statements require some database memory to store cached queries, which may pose a problem for you (though not always)