Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqowQ-00DeFV-Kf for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2025 08:22:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uqowP-003JeM-UR for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2025 08:22:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqowP-003JeD-DO for pgsql-performance@lists.postgresql.org; Tue, 26 Aug 2025 08:22:06 +0000 Received: from mail-ua1-x936.google.com ([2607:f8b0:4864:20::936]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqowN-001oCe-1W for pgsql-performance@lists.postgresql.org; Tue, 26 Aug 2025 08:22:05 +0000 Received: by mail-ua1-x936.google.com with SMTP id a1e0cc1a2514c-89411e87b20so132590241.0 for ; Tue, 26 Aug 2025 01:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756196523; x=1756801323; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=OpFHI1HzXn7JLIVJQkfkm1tLD/fwIMkVMr+fCyl0ZGM=; b=b04mMgyRpNaTk229w8PYWRQJhew2EEtI1HC27GYlf3qar5tfhMVcw90TbeDQ9Cqq1i 0JIdMN8QapOzMF87mNiG1hspvurPZ30Q9b0Z1xbl5skr5bcQVwdk+t/jEY64jp0JS+XM C7IqnWdzqrKhVkRDM0gmtg1HiwAk1J/k4+qqc4oM5zH/0Kymz2rGY/WNktZ6c1JTo3PW Dz4iPeiD30K9jgGqYr+2u8JftF0K/PKZowB0/cB2uCu8CJRyhbzKyMrQHgvjdybbxhTu BgodmSwzg9jjHcGE7Zw8G+vUa6uwFaJLIzzvrXOt5PP0Mykq3kSAqBwSBAA6Z5+606eX 7h3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756196523; x=1756801323; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=OpFHI1HzXn7JLIVJQkfkm1tLD/fwIMkVMr+fCyl0ZGM=; b=urzyU9bvOetLwKOzuGsrhhLIZeZhynLXVAZfLYD+E/UGcUwfzfAoIJ+fgvtwGkVYYi 0CZw7ESJE4x3eVM5eb8LezDSza/UBXMi16WQVAs9AxD/XJod2YQxxwJOgqMnG+10tRnL UYe6505NT93dZDq4K7+wL6f1lc2zn1arRKcApzB6gL8IHg+fZtzyy8ABMHPTIfXjlPYH 3IF9cXDIuC5vEL/+vzKH/eEJnQJmhMu0To8yyVwDlkXrnTNWajcnh1aUZP2icz2hd8BK qrj11J/MzuVUvMgl5Bvm9BPRHumfyXLMa/pmF1CaM4KzkWVPsQJcOpOBEYJe6CFXUgrq FP0w== X-Gm-Message-State: AOJu0YxAHzCLnZOySHZakxtgvexumpDA97g3MGXVJQP50cSgJproAF6v d6d1xUFBKTaBh5EGk834eZEpU4rWBpg1a6DKqGg9XM7iEB9Kh+JLnE7nlGDHlHjNBRY3MagRAXW OdycJFH5001BV4HZZLYJgRJhShuEnNg+US8uN X-Gm-Gg: ASbGncvmhXz/ETuLQmMy/zPMG4RAGB/amLdHp2X2oMu8/ahWDbb4nEMn/DDnpAS5YvF YJbrclA+0WLD0ybpu+CptfQrknHodgh+CSqL4HfcqE+Q/53iGSaWypaIAxAGRMR/HxIzfUkAXdG xTuDvEV6VWVGqCd5Ho8/h8H6eJ6oOKqi67ys8soFyQ8iDHTGELcwv2whCPA9BupD1ib1VQMywSn vX71WSxTwjDppl8Zj6IDFPuLYeY2/Vbrg98aNpoPSD2vvZW9PEhXAPczhhQfA== X-Google-Smtp-Source: AGHT+IFRpUK2jzz9dSGDFBKM0Yf5evuMsvtS/XvUyBKl6Ox75wyowRgkQyQG0IY+TAcLNtrSgt3ltdh/6ZeR8OL7Nsw= X-Received: by 2002:a05:6102:e0c:b0:4e7:be09:df07 with SMTP id ada2fe7eead31-5248bbce912mr155143137.12.1756196523003; Tue, 26 Aug 2025 01:22:03 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?B?RXJ0YW4gS8O8w6fDvGtvZ2x1?= Date: Tue, 26 Aug 2025 11:21:52 +0300 X-Gm-Features: Ac12FXx9Sx2MSr2KCVW_r-fSqraJGDLiFsYcHnXA1XZMIRkgBEup0LPO1yxy4dQ Message-ID: Subject: Keeping some tables in cache To: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000e8d707063d405d5a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000e8d707063d405d5a Content-Type: text/plain; charset="UTF-8" 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 --000000000000e8d707063d405d5a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

I read a lot of different s= uggestions 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 c= ores (2.59Ghz Xeon SapphireRapids) and 4GB RAM.
On average 1.7 to= 2.0GB of RAM is actively used on that server.
Disk performance i= s not great at all.
I have no other choice to use that server as = it is provided.

I used pgtune web site optimized c= onfiguration tool and relevant parameters in my postgresql.conf are as foll= owing:
max_connections =3D 200
shared_buffers =3D 1GB
effec= tive_cache_size =3D 3GB
maintenance_work_mem =3D 256MB
checkpoint_com= pletion_target =3D 0.9
wal_buffers =3D 16MB
default_statistics_target= =3D 100
random_page_cost =3D 1.1
work_mem =3D 5041kB
huge_pages = =3D off
min_wal_size =3D 1GB
max_wal_size =3D 4GB

My database size is way too small and not even 200 MB.
Ther= e are about 6-7 tables where some of them are empty, some of them have sing= le 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 the= re maybe updates more frequent than now in the future.

=
My problem is, I am running a time bound web service on the same serve= r 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 thi= ngs, using other tables, running different queries depending on user select= ions on the same database.
There are other scheduled jobs on that= same system doing some other web service communication including select/in= sert/update interaction with the same database.
Finally, there ar= e hourly backups using pg_dump and 7zip.

What I wo= uld 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 d= on't know maybe this is already how PostgreSQL works).
This w= ould 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 ser= vice tables in another database.

Any help is= appreciated.

Thanks & Regards,
Erta= n
--000000000000e8d707063d405d5a--