2

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?

Andrius
  • 19,658
  • 37
  • 143
  • 243
  • 1
    You're not running postgres with a ramdisk: you've set `PGDATA` to `/pgtmpfs`, but you're never mounting anything on `/pgtmpfs` so it's just another directory on the filesystem. – larsks Jan 05 '23 at 16:08
  • A, right. Stupid me. I thought it was weird that in that sample, different dirs were used than in PGDATA..:). Now I see it uses memory, but speed is still the same. Thats a bummer:) – Andrius Jan 05 '23 at 16:19

0 Answers0