cardano-foundation / cardano-graphql

GraphQL API for Cardano
Apache License 2.0
263 stars 104 forks source link

Why does cardano-graphql-v7.0.0 use 1.8T disk space #808

Closed apufvqsp closed 1 year ago

apufvqsp commented 1 year ago

Ask a question

hi

I am using cardano-graphql-v7.0.0, it has been running for 4 months, and now I find that it takes up 1.8T of disk space,

is this a normal disk usage? Is there a way to reduce disk usage?

airstring commented 1 year ago

How did you deploy ada?My node takes up 700G of disk space.

infnada commented 1 year ago

I also had an unusual increment of disk space in the Asset table caused by an error in Psql Toast. Thats a big shot without more info from your side but what i would do:

  1. Check which table/s is using this much space:

https://stackoverflow.com/a/52706756

Modified version:

select current_database() as database,
       pg_size_pretty(total_database_size) as total_database_size,
       schema_name,
       table_name,
       pg_size_pretty(total_table_size) as total_table_size,
       pg_size_pretty(table_size) as table_size,
       pg_size_pretty(index_size) as index_size
       from ( select table_name,
                table_schema as schema_name,
                pg_database_size(current_database()) as total_database_size,
                pg_total_relation_size(quote_ident(table_name)) as total_table_size,
                pg_relation_size(quote_ident(table_name)) as table_size,
                pg_indexes_size(quote_ident(table_name)) as index_size
                from information_schema.tables
                where table_schema=current_schema()
                order by total_table_size
            ) as sizes;
  1. check for any table where index_size + table_size != total_table_size
  2. perform a VACUUM FULL "TABLE_NAME"; on the tables affected
  3. if you have Toast error like me you can follow https://stackoverflow.com/a/68194898 to solve it

My DB is ~300GB but Assets metadata are not fully synced

NOTE: i'm not a psql DBA and i'm not using this in PROD environment. DYOR before executing anything