public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tim Schwenke <[email protected]>
To: David G. Johnston <[email protected]>
Cc: Pgsql Novice <[email protected]>
Subject: Re: Does PostgreSQL cache all columns of a table after SELECT?
Date: Mon, 05 Jun 2023 15:17:17 +0200
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAKFQuwamUDxtmA3G4mUP1y4DvntoJ4EA4o02465dfiRO3O9rBQ@mail.gmail.com>
References: <[email protected]>
	<CAKFQuwamUDxtmA3G4mUP1y4DvntoJ4EA4o02465dfiRO3O9rBQ@mail.gmail.com>

Hello David,

from what I understand, in PostgreSQL, tables are stored in one or more files called segments. There is no separation by columns.

https://www.postgresql.org/docs/8.1/storage.html

This means if I select a single column from a table the first time, the full file / segment is read and put into page cache if there is enough space. This means a table with only one large column large_a takes up less page cache compared to a table with many large columns large_a and large_b, even though in both cases only large_a is selected.

Is that more or less correct? Ignoring toast?

Tim S.

---- On Mon, 05 Jun 2023 14:58:21 +0200 David G. Johnston  wrote ---

 > 
 > 
 > On Monday, June 5, 2023, Tim Schwenke [email protected]> wrote:
 > 
 > 
 > Does the cache also contain large_b? Or is only large_a cached? Assumption is that memory is large enough to fit everything.
 > 
 > 
 > Shared buffers is a page cache.
 > 
 > David J. 
 > 






view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Does PostgreSQL cache all columns of a table after SELECT?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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