Connection.execute or Connection.prepare for optimizing similar queries #331
Unanswered
I-m-good-man
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The Connection.execute and Connection.prepare methods create a prepared statement under the hood. however, connection.execute creates it and immediately releases it after execution. and connection.prepare holds the prepared statement until the session is closed, or until it is released using DEALLOCATE (Statement.dispose).
I am writing an ORM and trying to figure out which approach is better for me to use if I need to make many similar queries:
1) If you use Connection.execute, then there is an overhead for creating and deleting a prepared statement and there is no performance optimization for subsequent requests that prepared statement provides.
2) If you use Connection.prepare, a lot of memory will be spent on the content of the prepared statement, but there will be no overhead for creating/deleting and similar queries will be executed quickly.
What is the best way to make the same type of queries?
Beta Was this translation helpful? Give feedback.
All reactions