asyncpg icon indicating copy to clipboard operation
asyncpg copied to clipboard

Avoiding introspection queries for built-in array types

Open 0xD09CD196D188D0B0 opened this issue 3 months ago • 0 comments

Hi, and thanks for all the work on asyncpg! 👋

I’ve noticed that fresh connections usually emit introspection queries even for statements involving simple arrays of integers.

Looking at the code in init_array_codecs, asyncpg seems to initialize only the core codecs for _oid and _text (as mentioned in the comment, “to make type introspection query work”).

https://github.com/MagicStack/asyncpg/blob/5b14653e0b447d956aa01ec658562138e19f0293/asyncpg/protocol/codecs/array.pyx#L861-L875

I was wondering: was there a particular reason that asyncpg doesn’t include more built-in types there? From my perspective, types like _int2, _int4, _int8, _float4, _float8, _bool, and _char are very commonly used in queries. Including them might avoid a lot of introspection queries on new connections.

Is this something that could be considered, or are there trade-offs I might be missing?

0xD09CD196D188D0B0 avatar Sep 04 '25 12:09 0xD09CD196D188D0B0