-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Queries on tables that use CITEXT are 4x slower when using Supavisor vs a direct connection to the db #300
Comments
Interesting. Thank you for the detail here! Maybe something in the wire protocol causes more round trips for citext tables. We don't do anything specific for any types. |
Thank you for taking a look. I didn't imagine anything was being done specifically with types. Round trips sounds like a good path to investigate since I noticed adding 1 CITEXT type was faster than adding 3. I imagine adding more would slow it down further. It also seemed like the timing scales relative to the overall single query time. |
I had a bit of time to point my development instance of supavisor to an eu-west-2 supabase DB. These are the logs from the same query with three different column type configurations. Query (no CITEXT columns):
Supavisor:
Query (email, firstName, lastName as CITEXT):
Supavisor:
I also did a query on users where only the Query (email is CITEXT):
Supavisor:
|
I have been able to reproduce this with PgBouncer now so it is seeming more likely that this has to do with CITEXT and transaction mode that we use for the connection poolers. Users table has CITEXT for firstName, lastName and email.
Users table has no CITEXT columns.
It seems to me that at this point the CITEXT extension is incompatible with transaction mode for production purposes. I will work towards finding an alternative. |
I created a configuration with Cloudflare that seems to avoid this issue. Remix (drizzle w/ HTTP proxy) -> CF Worker (connected using a service binding) -> Hyperdrive (CF Pooler) -> DB (direct connection 5432) I added 10 CITEXT columns to a table and didn't notice any major difference in the query times compared to a table without this type. |
Bug report
Originally searched on discord and posted there, the amazing garyaustin suggested I post the issue on the Supavisor GitHub. https://discord.com/channels/839993398554656828/1204584952029782026
I also tested this issue with a local install of Supavisor following the instructions found here: https://supabase.github.io/supavisor/
Describe the bug
Queries to tables that use the CITEXT type are taking longer than queries on tables that do not use this type. Even if the query is
select * from table
. This bug can be described as weird because it does not seem to occur when connecting to the database directly.Background:
We setup a Supabase instance in eu-west-2, but are doing the development in us-west. This means that our queries have about 110ms of extra latency which is acceptable. Recently we noticed that queries to the
users
table are taking about 1200-1500ms while queries to other tables are taking less than 300ms. We recently switched to the Supavisor pooler, and do not recall if the queries were slow when we were using PGbouncer.In an attempt to isolate the issue to Prisma, I tried Drizzle. The queries with Drizzle are also slow on the
users
tables. The query performance in the Supabase monitoring shows 0.04ms for this query after resetting and running it.To Reproduce
postgres://postgres.tenant:[email protected]:6543/postgres?pgbouncer=true
select * from users
and record the duration.select * from centres
and record the duration.Expected behavior
The queries should take the same duration when using the connection pooler.
Logs
Connection to Supavisor eu-west-2 (no CITEXT):
Connection to Supavisor eu-west-2:
Connection to Postgres directly using 5432 (no CITEXT):
Connection to Postgres directly using 5432:
Additional context
The logs show that the query for
centres
is approximately the same duration with or without he connection pooler. Theusers
table query duration matches when CITEXT isn't used as a column type within the table. The duration increases as the table uses more columns that with the CITEXT type.The text was updated successfully, but these errors were encountered: