You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unless you're actually running into a situation where the hashmap lookup for the prepared statement is a significant source of overhead, I don't think it's worth the effort. Being a hashmap, lookups are going to be quite fast (relatively speaking) up to probably several hundred thousand elements.
Where a significant overhead is likely to occur on maps of that size is on insert, when the map needs to resize itself and thus rehash all its elements.
However, you'd need to execute that many unique queries on a single connection for this to become an issue, which is only likely to come up if you're dynamically generating queries. In that case I think we just need a way to say "prepare this statement, but don't cache it" which I already have in mind for implementing #875 and we can expose that for users to set as well.
To execute each query, sqlx needs to find the cached statement even for statement object already provided.
For example:
Statement provided:
Statement not provided:
And see
get_or_prepare
:https://github.com/launchbadge/sqlx/blob/master/sqlx-core/src/postgres/connection/executor.rs#L173
If the map is big, then the find would be an unnecessary overhead.
The text was updated successfully, but these errors were encountered: