PostgreSQL in Memory (with docker compose) - validate if its working?

309 Views Asked by At

I tried this approach from here: https://stackoverflow.com/a/42239760/1455384

So I have this kind of db setup:

  db:
    # 15.1-alpine3.16
    image: postgres@sha256:44b4073d487d0f9baf82bc95d10e2b1f161b18dcc52cfbd0eb2a894b5e2cd513
    environment:
      <<: *common-variables
      PGDATA: /pgtmpfs
    tmpfs:
      - /run:size=131072k
      - /var/cache:size=65536k
    networks:
      - backend

When I run my application with this kind of postgres setup, I don't really notice any difference in speed (for example when I run various tests that hit database, they finish in about 2 minutes, whether tmpfs is used or not).

Also if I run: docker exec -it demo-db-1 df /run

I see:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   131072         4    131068   0% /run

Does 0% Use mean, postgres does not actually use that memory "block" from tmpfs?

Update

Changing to:

tmpfs:
  - /pgtmpfs:size=131072k

makes it properly use memory, but speed is not changed. Not sure if thats, because postgres does not really benefit from this or because something else is wrong?

0

There are 0 best solutions below