MagicStack / MagicStack/asyncpg

Avoiding introspection queries for built-in array types

Open
#1,272 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
8.1k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with asyncpg/protocol/codecs/array.pyx, especially init_array_codecs and the linked lines around 861-875. Review how _oid and _text are initialized, then assess the listed built-in array types and whether including them avoids introspection queries without the trade-offs raised in the issue. Done means a clear decision and an appropriate change or documented rationale.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, python
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.