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

From: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
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:25:08
Message-ID: Z7OpNGOpf3Ad1OOI@elch.exwg.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

## Ron Johnson (ronljohnsonjr(at)gmail(dot)com):

> 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?
>
> $ time psql -h foo bar -Xc "DO \$\$ BEGIN PERFORM * FROM mytbl ORDER BY id
> DESC LIMIT 200000 ; END \$\$;"

You can check what that statement does - e.g. in pg_stat_statements,
or (on an idle database, so the effects aren't lost in the noise) in
pg_stat_database or pg_statio_user_tables.
Between what the storage components of the last decade (e.g. those
SATA SSDs which are already being replaced in the market by NVME)
can deliver (>400MB/s, often marketed as ">500 MB/s" but on SATA that's
optimistic) and the fact that there are most likely some blocks
in the database' buffer and/or the OS buffer, the observed throughput
is not neccessarily unrealistic. With modern "server" hardware, getting
throughput in the "gigabytes per second" range is considered normal and
expected.

Regards,
Christoph

--
Spare Space

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Haas 2025-02-17 21:34:45 Re: Clarification on Role Access Rights to Table Indexes
Previous Message Ron Johnson 2025-02-17 20:32:47 Loading the latest N rows into the cache seems way too fast.