asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

Introspection TYPE_BY_OID running for long time

Open slice-ArpitSharma opened this issue 11 months ago • 4 comments

  • asyncpg version:.29.0
  • PostgreSQL version: 2.0.26
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce the issue with a local PostgreSQL install?: no
  • Python version: 3.8.12
  • Platform: macos | arm | m1
  • Do you use pgbouncer?: no
  • Did you install asyncpg with pip?: yes
  • If you built asyncpg locally, which version of Cython did you use?: na
  • Can the issue be reproduced under both asyncio and uvloop?: haven't tried yet

Recently integrated Postgres db in of my services, it is a fastapi application hence I am leveraging asyncpg and sqlalchemy, however ever since I've done that, the db is executing the query SELECT t.oid, t.typelem AS elemtype, t.typtype AS kindFROM pg_catalog.pg_type AS tWHERE t.oid = $1

upon inspection I found that it is executed through asyncpg while introspection, using the TYPE_BY_OID introspection type.

The RDS metrics looks like this Screenshot 2024-03-20 at 1 06 59 AM

Need some help in understanding why it is happening, and how can we stop it.

In the service there is a global pg_session. ENGINE pg_engine = create_async_engine( os.environ.get('PG_CONN_STRING'), pool_size=5, max_overflow=7, connect_args={"server_settings": {"jit": "off"}} ) SESSION pg_async_session = async_sessionmaker(pg_engine, expire_on_commit=False) for each query we start the connection , execute the query using ORMs and commit. async with pg_async_session() as session:

slice-ArpitSharma avatar Mar 19 '24 20:03 slice-ArpitSharma

@elprans please share your perspective on this problem.

slice-ArpitSharma avatar Apr 04 '24 06:04 slice-ArpitSharma

@slice-ArpitSharma Any updates on this? We're pretty much having the same problem, although we're using SQLAlchemy in addition.

zagortenej024 avatar Apr 24 '24 21:04 zagortenej024

@zagortenej024 no updates, i am also using sqlalchemy

slice-ArpitSharma avatar Apr 26 '24 06:04 slice-ArpitSharma

@slice-ArpitSharma Any updates on this? Do you use NullPool in SQLAlchemy?

amaksymov avatar Sep 25 '24 19:09 amaksymov