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 1uqsgd-00EZzs-Eg for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2025 12:22:04 +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 1uqsgc-005gQ5-SK for pgsql-performance@arkaria.postgresql.org; Tue, 26 Aug 2025 12:22:03 +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 1uqsgc-005gPx-HG for pgsql-performance@lists.postgresql.org; Tue, 26 Aug 2025 12:22:03 +0000 Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqsga-001q4R-2S for pgsql-performance@lists.postgresql.org; Tue, 26 Aug 2025 12:22:02 +0000 Received: by mail-ej1-x636.google.com with SMTP id a640c23a62f3a-afcb7a8dd3dso826455466b.3 for ; Tue, 26 Aug 2025 05:22:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1756210920; x=1756815720; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=TzMmf1BjT/s1y4Y/GAU25MstZgR7TQ23AUSd2O8GLXI=; b=mgyGK/LZn5U/I3mEIh2NhV1bGsk37JlWOg9VPhZf1uc4/DkRzKgkwk7DnnkvPYuAYq kiIoL0F5jgMlAY/E8TaquGzteTSjvc2z7Sn8tQWwqpippYhknzA8EpUdpg7X2z3TNYXa FhKjJxdCHfB8WSKlw2zb5M1xFKpzWSUskp/KzBLhIIW6dIseiWKCnHBWhPIs6qnwnJk0 hPTVRe0FEN9TDyKeOrRi3HIEWFF0fGJ/o5rOcxMNo0EtPwQFRa6L5VD7JgD3FawY1eJ3 Sr+6NUP4TZYpslj4DVA2k2QGd0aZfXDiAmAkXsjHy+BEYmfhY7S46unHygzLHQ2/0HA1 AnLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756210920; x=1756815720; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TzMmf1BjT/s1y4Y/GAU25MstZgR7TQ23AUSd2O8GLXI=; b=mNk3DoUBv6mcWl7SfmmF4XBLdB5fH5PdPHw69B+rsmZsNSCEd7SyJ1dggCSpGGx7xU sOqQU0JK5VkFyYFjxUemU3mpuhJ+n9+znzxW3rzvkgiYk3poHfmcIH641RfAJsU6w84l QM9Tr7cUhpNko6ZRGqtlPpIe9HQoF/jdKssEBqlh5AdkdHf4MEWV4LLmW0bU8Qhva1p/ 5PCwE6PlFjFhjKRe5xZT8/1jxqT6WtBZbeyNbdi/k9rx6NATbY6aAZIaAJeRytCU/VYZ M5CVDPGGTNFNZFxaCWqo3aGG9aAx0uJlIAYIV5LKVDY5rgOYANcPcJQBsBX/5bQowjkI cLJA== X-Forwarded-Encrypted: i=1; AJvYcCUlHbgzGfsNnbSwJwnZntaDRJKiiVu/UW8avqzunpwnilLeo1IiN1HBSr0s+bQQnwvHrMv9YmQHFSQgYe0xojESGA==@lists.postgresql.org X-Gm-Message-State: AOJu0YzDsAgxZQpO5nUmpw7EkcKSSqUUd9H6PLyvMoAHXYHFqobVD2X8 cE5RfqW5cCp4qwPptm27YEaixPz/Lh89HiCESAad8QuzWwlr8NI9eZowjwk8AIwdn2Y= X-Gm-Gg: ASbGncsnAXC2gUMmkNxg7SH4I5g5L5cKUUeCx17e0ziuz2vJGTvNYCxvFuIpuzbiXiC kACQkQBGkVdmSauX9Z0fBJYw4MBfPuQu8YCmueMKu890G4BPk7rlTDGmln8myQ1YBzccfMF3SJO MxVtDrcbKj7zf3QCxljPKFob62ym12ZKAPWj6fQqegTDn9R/W0M5JBI5XigrhcU4DzHhzyScTQ9 dxbQA4rbf7DJppIhCan5dx+2RC1dxG+FW6b2eqYNOqOpSbtH5D22e3bEHzBMT+eMBetvIS3rGFJ FMyLLQQwpj9m3gh/dFX9V73wkirYIL/7N7Y3fKbBmzKye2YObnB/vRg1TpwBwTG2MsXEelkapVj mKBoHrLo5YwsORbOA5qRW+vYbQJIfUPPEhFQvk6AyfS9lEMIvYR8= X-Google-Smtp-Source: AGHT+IETE0op6R8zrTnCsaItfDgm3YPgmDgSfOOWmvfBVEWc0dTWceK6KJM7muC2AHk59HM30HCYLQ== X-Received: by 2002:a17:906:6a02:b0:afc:f12b:8a85 with SMTP id a640c23a62f3a-afe2958a89cmr1443600966b.34.1756210919937; Tue, 26 Aug 2025 05:21:59 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-afe7fd59b00sm419017666b.106.2025.08.26.05.21.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Aug 2025 05:21:59 -0700 (PDT) Message-ID: <835091f124435baf195c331d79641cea95ddf451.camel@cybertec.at> Subject: Re: Keeping some tables in cache From: Laurenz Albe To: Ertan =?ISO-8859-1?Q?K=FC=E7=FCkoglu?= , pgsql-performance@lists.postgresql.org Date: Tue, 26 Aug 2025 14:21:59 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-08-26 at 11:21 +0300, Ertan K=C3=BC=C3=A7=C3=BCkoglu wrote: > 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. >=20 > I used pgtune web site optimized configuration tool and relevant paramete= rs in > my postgresql.conf are as following: > max_connections =3D 200 > shared_buffers =3D 1GB > effective_cache_size =3D 3GB > maintenance_work_mem =3D 256MB > checkpoint_completion_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 >=20 > My database size is way too small and not even 200 MB. >=20 > My problem is, I am running a time bound web service on the same server w= hich needs >=20 > What I would like is to keep these small tables in RAM all the time and i= f 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). That will happen automatically: all data you read or modify get loaded into shared buffers and stay there. The cache will be empty after a restart of the database. You can use the pg= _prewarm extension (in shared_preload_libraries) for PostgreSQL to load the data int= o the cache again automatically after a restart. Yours, Laurenz Albe