public inbox for [email protected]  
help / color / mirror / Atom feed
Re: postgres in swap space
4+ messages / 4 participants
[nested] [flat]

* Re: postgres in swap space
@ 2025-11-17 20:49 Laurenz Albe <[email protected]>
  2025-11-17 21:12 ` Re: postgres in swap space Ron Johnson <[email protected]>
  2025-11-18 03:07 ` Re: postgres in swap space Bruce Momjian <[email protected]>
  2025-11-18 20:23 ` Re: postgres in swap space Marc Millas <[email protected]>
  0 siblings, 3 replies; 4+ messages in thread

From: Laurenz Albe @ 2025-11-17 20:49 UTC (permalink / raw)
  To: Marc Millas <[email protected]>; [email protected] <[email protected]>

On Mon, 2025-11-17 at 18:25 +0100, Marc Millas wrote:
> Can someone point me to any doc describing why and how much space postgres uses on the swap of a debian machine ?
> it's an old postgres 10, because it is used by a product for which only this version is certified.
> (no comment on that, please)

I'm biting down a comment.

PostgreSQL itself doesn't use any swap space.

The kernel can decide to swap out memory used by PostgreSQL.  How much that is depends
on how you configured the Linux kernel and how much memory PostgreSQL uses.  The latter
is mostly determined by "shared_buffers", "work_mem", "maintenance_work_mem" and
"max_connections".

On the kernel side, it is mostly the "vm.swappiness" parameter that determines how
eager the kernel is to swap out memory, even if there is no pressure.  For best
performance, that should happen as little as possible, and the database should
determine what to keep in memory and what to store on disk.

One tool you have to prevent shared buffers from being swapped out is to define enough
Linux hugepages, so that PostgreSQL can allocate shared buffers there.  Linux does not
swap out hugepages.

You can find the PostgreSQL parameters described in the PostgreSQL documentation and the
kernel parameters in the kernel documentation.

Yours,
Laurenz Albe






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: postgres in swap space
  2025-11-17 20:49 Re: postgres in swap space Laurenz Albe <[email protected]>
@ 2025-11-17 21:12 ` Ron Johnson <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: Ron Johnson @ 2025-11-17 21:12 UTC (permalink / raw)
  To: [email protected] <[email protected]>

On Mon, Nov 17, 2025 at 3:50 PM Laurenz Albe <[email protected]>
wrote:

> On Mon, 2025-11-17 at 18:25 +0100, Marc Millas wrote:
> > Can someone point me to any doc describing why and how much space
> postgres uses on the swap of a debian machine ?
> > it's an old postgres 10, because it is used by a product for which only
> this version is certified.
> > (no comment on that, please)
>
> I'm biting down a comment.
>

"If it ain't broke, don't fix it" works just fine (until it doesn't).

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: postgres in swap space
  2025-11-17 20:49 Re: postgres in swap space Laurenz Albe <[email protected]>
@ 2025-11-18 03:07 ` Bruce Momjian <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: Bruce Momjian @ 2025-11-18 03:07 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: Marc Millas <[email protected]>; [email protected] <[email protected]>

On Mon, Nov 17, 2025 at 09:49:59PM +0100, Laurenz Albe wrote:
> On Mon, 2025-11-17 at 18:25 +0100, Marc Millas wrote:
> > Can someone point me to any doc describing why and how much space postgres uses on the swap of a debian machine ?
> > it's an old postgres 10, because it is used by a product for which only this version is certified.
> > (no comment on that, please)
> 
> I'm biting down a comment.
> 
> PostgreSQL itself doesn't use any swap space.
> 
> The kernel can decide to swap out memory used by PostgreSQL.  How much that is depends
> on how you configured the Linux kernel and how much memory PostgreSQL uses.  The latter
> is mostly determined by "shared_buffers", "work_mem", "maintenance_work_mem" and
> "max_connections".

I wrote a blog entry about swap space:

	https://momjian.us/main/blogs/pgblog/2012.html#July_25_2012

-- 
  Bruce Momjian  <[email protected]>        https://momjian.us
  EDB                                      https://enterprisedb.com

  Do not let urgent matters crowd out time for investment in the future.






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: postgres in swap space
  2025-11-17 20:49 Re: postgres in swap space Laurenz Albe <[email protected]>
@ 2025-11-18 20:23 ` Marc Millas <[email protected]>
  2 siblings, 0 replies; 4+ messages in thread

From: Marc Millas @ 2025-11-18 20:23 UTC (permalink / raw)
  To: Laurenz Albe <[email protected]>; +Cc: [email protected] <[email protected]>

Clear !
thanks Laurentz

Marc MILLAS
Senior Architect
+33607850334
www.mokadb.com



On Mon, Nov 17, 2025 at 9:50 PM Laurenz Albe <[email protected]>
wrote:

> On Mon, 2025-11-17 at 18:25 +0100, Marc Millas wrote:
> > Can someone point me to any doc describing why and how much space
> postgres uses on the swap of a debian machine ?
> > it's an old postgres 10, because it is used by a product for which only
> this version is certified.
> > (no comment on that, please)
>
> I'm biting down a comment.
>
> PostgreSQL itself doesn't use any swap space.
>
> The kernel can decide to swap out memory used by PostgreSQL.  How much
> that is depends
> on how you configured the Linux kernel and how much memory PostgreSQL
> uses.  The latter
> is mostly determined by "shared_buffers", "work_mem",
> "maintenance_work_mem" and
> "max_connections".
>
> On the kernel side, it is mostly the "vm.swappiness" parameter that
> determines how
> eager the kernel is to swap out memory, even if there is no pressure.  For
> best
> performance, that should happen as little as possible, and the database
> should
> determine what to keep in memory and what to store on disk.
>
> One tool you have to prevent shared buffers from being swapped out is to
> define enough
> Linux hugepages, so that PostgreSQL can allocate shared buffers there.
> Linux does not
> swap out hugepages.
>
> You can find the PostgreSQL parameters described in the PostgreSQL
> documentation and the
> kernel parameters in the kernel documentation.
>
> Yours,
> Laurenz Albe
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2025-11-18 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-11-17 20:49 Re: postgres in swap space Laurenz Albe <[email protected]>
2025-11-17 21:12 ` Ron Johnson <[email protected]>
2025-11-18 03:07 ` Bruce Momjian <[email protected]>
2025-11-18 20:23 ` Marc Millas <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox