-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enum and array in preparated statement hammer performance #782
Comments
a bit more investigating and this is not related to If I run the following: with debug.timer('select'):
await conn.execute(
'select $1::user_spam, $2::varchar[]',
'bar', ('foo', 'bar')
)
with debug.timer('select'):
await conn.execute(
'select $1::user_spam, $2::varchar[]',
'bar', ('foo', 'bar')
) Only the first query is slow. |
Try disabling jit in Postgres config or in |
Yes, that solves the problem. Thanks so much. Is there any concensus on whether to disable the jit in production? E.g., if I reuse a connection so first queries aren't significant does anyone know if the jit really improves performance? |
It only makes sense for queries that do lots of computation in complex expressions over a large number of rows. Unfortunately, Postgres deems asyncpg's introspection query as "complex" and triggers JIT compilation on it, even though the query isn't that complicated, just large. |
thanks. |
This is a frequent source of grief, actually, there's been a bunch of reports like this, so we might want to put a mitigation in place and disable |
asyncpg==0.23.0
(also tested withasyncpg==0.21.0
PostgreSQL 13.3 (Ubuntu 13.3-0ubuntu0.21.04.1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 10.3.0-1ubuntu1) 10.3.0, 64-bit
Python 3.8.10
uvloop?: yes, makes no different
I have no idea what's going on here, there's a very weird (and big!) performance impact sometimes when you use an enum and a list/array together as prepared arguments.
I had this on a production system, but here is a minimal reproduction of the problem (
debug
is just here to test performance, it makes not difference:Output:
For now my work around is to use simple
varchar
fields instead ofenums
, but I'd love to know why this is happening.The text was updated successfully, but these errors were encountered: