hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
30.95k stars 2.74k forks source link

Hasura metadata API slows down as amount of tables increases #9989

Open spovedavoladi opened 7 months ago

spovedavoladi commented 7 months ago

I have a multi-tenant Hasura application, and the tracking performance degrades with every increase in the number of the tables tracked in the database.

Is this intended behavior? How can I help my application perform tracking updates when there is a small schema change such as a new table in any given schema, so that it doesn't take 30 seconds to track the new table if I have 2000 other tables in the db?

Version Information

Server Version: v2.33.4 CLI Version (for CLI related issue):

Environment

Self hosted graphql container running in Docker PostgreSQL 14.5 on x86_64-pc-linux-musl, compiled by gcc (Alpine 11.2.1_git20220219) 11.2.1 20220219, 64-bit

What is the current behaviour?

Tracking tables/creating object/array relations takes an increasing amount of time as the amount of tables in the DB increases.

What is the expected behaviour?

The time it takes to track a single table should not increase proportionally to the amount of tables contained in the database.

How to reproduce the issue?

  1. Fill up the database with more, tracked, tables; as the amount of tables increases, the time it takes to query the API increases as well.

Example using a python function that calls the Hasura metadata api using the requests library, and using the pg_track_tables tracks a single table after it has been created and added to the database:

# 0 tables in the DB
func: track_tables took: 0.53 sec
...
# +1700 tables in the DB (even in different schemas, amount of schemas doesn't matter)
func: track_tables took: 9.85 sec

Keywords

Slow, track, tables, timeout

tramitasoft commented 6 months ago

+1 It's incredibly slow...

fatjoni commented 6 months ago

+1 ultra increadibly slow..

asmitzz commented 5 months ago

+1 It is getting slow everytime I create new table.

DoonPort0422 commented 1 month ago

+1 it's still very very slow