Re: Loading the latest N rows into the cache seems way too fast.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Loading the latest N rows into the cache seems way too fast.
Date: 2025-02-17 21:58:53
Message-ID: CAKFQuwbLa1d4DMRQsYMzJ7OwcTCHYvuKcG7RD5meC0ryP_Za4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Feb 17, 2025 at 2:41 PM Ron Johnson <ronljohnsonjr(at)gmail(dot)com> wrote:

> On Mon, Feb 17, 2025 at 4:36 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
>> Ron Johnson <ronljohnsonjr(at)gmail(dot)com> writes:
>> > The bigint "id" column in "mytbl" is populated from a sequence, and so
>> is
>> > monotonically increasing: the newest records will have the biggest id
>> > values.
>> > The table also has a bytea column that averages about 100KB.
>>
>> > Loading 200K rows is more than 200MB. I expected this "prewarm"
>> statement
>> > to take much longer than 1/2 second. Am I still in the dark ages of
>> > computer speed, or is this statement not doing what I hope it's doing?
>>
>> It's not pulling in the TOAST storage where the bytea column lives.
>> (pg_prewarm wouldn't have either, without special pushups.)
>>
>
> Puzzling, since I ran "PERFORM *". What if I explicitly mentioned the
> bytea column's name?
>
>
It's more about the system optimizing away data retrieval because you've
indicated you don't care about the contents due to using PERFORM. All it
needs is a pointer to represent the future data, not the data itself. And
PERFORM will never resolve that pointer by itself - so as Tom said your
query would need to force pointer resolution by computing on the data.

David J.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2025-02-17 22:02:03 Re: Clarification on Role Access Rights to Table Indexes
Previous Message Tom Lane 2025-02-17 21:51:10 Re: Loading the latest N rows into the cache seems way too fast.