0

I have a PostgreSQL database on a docker container with 50MB of data:

SELECT pg_size_pretty(pg_database_size('db_1'));
 pg_size_pretty 
------------------
 50 MB

but the volume size is 8.5GB :

sudo du -hd1 db_volume
8.5G    db_volume

and my docker-compose is like this:

version: '3.8'

services:
  r3-db:
    image: postgres:12
    restart: always
    ports:
      - 5432:5432
    environment:
      POSTGRES_PASSWORD: PASSWORD
      POSTGRES_USER: USER
      POSTGRES_DB: db_1
    volumes:
      - ./db_volume/:/var/lib/postgresql/data:Z

I try using VACUUM(FULL, ANALYZE, VERBOSE) on any table but the file size of the database doesn't change!

The volume contains many files named core.NUMBER with size of 145MB,

enter image description here

How can I reduce disk usage of the database?

1 Answer 1

1

Those are core dumps which are generated when PostgreSQL crashes. You can use them with gdb to perhaps figure out why it is crashing. You can delete them. You can save one to use it to figure out why PostgreSQL keeps crashing, as that should absolutely not be happening. Also look in the PostgreSQL log file for info on why it is crashing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.