Keeping some tables in cache

From: Ertan Küçükoglu <ertan(dot)kucukoglu(at)gmail(dot)com>
To: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Keeping some tables in cache
Date: 2025-08-26 08:21:52
Message-ID: CAH2i4yeOU11Co792H0F2EbosQW3bsUuGRs=kQgxuFLCfNkHcYQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hello,

I read a lot of different suggestions on the web and finally confused and
decided to ask in here.
Same/similar questions are asked before like 14 years ago 7 years ago, etc.
and I also wanted to learn the latest news.

I am using PostgreSQL 17.6 on Win64 platform running on VPS with 4 cores
(2.59Ghz Xeon SapphireRapids) and 4GB RAM.
On average 1.7 to 2.0GB of RAM is actively used on that server.
Disk performance is not great at all.
I have no other choice to use that server as it is provided.

I used pgtune web site optimized configuration tool and relevant parameters
in my postgresql.conf are as following:
max_connections = 200
shared_buffers = 1GB
effective_cache_size = 3GB
maintenance_work_mem = 256MB
checkpoint_completion_target = 0.9
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
work_mem = 5041kB
huge_pages = off
min_wal_size = 1GB
max_wal_size = 4GB

My database size is way too small and not even 200 MB.
There are about 6-7 tables where some of them are empty, some of them have
single row in it, some of them have a few rows only.
These tables are 99% of the time select queried and rarely updated. That
may change and there maybe updates more frequent than now in the future.

My problem is, I am running a time bound web service on the same server
which needs to reply incoming requests under 2.0 seconds.
These 6-7 tables are only queried if certain request reaches to the web
service.
There are other web services on that same system doing other things, using
other tables, running different queries depending on user selections on the
same database.
There are other scheduled jobs on that same system doing some other web
service communication including select/insert/update interaction with the
same database.
Finally, there are hourly backups using pg_dump and 7zip.

What I would like is to keep these small tables in RAM all the time and if
there is a change to their data I also want to have it reflected into the
cache (I don't know maybe this is already how PostgreSQL works).
This would support this tme bound service a lot on this server.

I don't know how PostgreSQL cache system works in detail. If there is a
setting for per database then maybe I can move time bound service tables in
another database.

Any help is appreciated.

Thanks & Regards,
Ertan

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Achilleas Mantzios 2025-08-26 09:04:31 Re: Keeping some tables in cache
Previous Message Frédéric Yhuel 2025-08-19 17:40:10 Re: Safe vm.overcommit_ratio for Large Multi-Instance PostgreSQL Fleet