Skip to content

Clarification on prepared statements #565

@mikmatko

Description

@mikmatko

Gino seems to support prepared statements to some extent. As there is no documentation yet, could you please clarify how the prepared statements currently work.

What is the relationship between Gino prepared statements, Sqlalchemy and asyncpg? As far as I understand,

  • Sqlalchemy does not support prepared statements
  • Asyncpg supports prepared statements

But as per MagicStack/asyncpg#51 (comment)

  • Asyncpg caches queries internally and discourages the use of prepared statements in most cases
  • Prepared statements are per-connection

So,

  • Does Gino utilize the LRU cache used internally by asyncpg? Does connection pooling affect this? Or is Gino simply unaware of any of the asyncpg internals regarding these?
  • => should prepared statements generally be utilized for repeated queries?
  • => what would be the way to approach repeated queries, e.g. we have an insert statement that is repeated thousands of times (with different values of course)

Thank you for your time!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionA community question, closed when inactive.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions