| From: | Ron Johnson <ronljohnsonjr(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Loading the latest N rows into the cache seems way too fast. |
| Date: | 2025-02-17 20:32:47 |
| Message-ID: | CANzqJaBTPgTJ_M3dGiOa5H-FvAo71oCCa1QHejbzK+joKdrSyw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
PG 9.6.24 and PG 14.15, if it matters.
(Yes, 9.6 is really EOL. I don't control that.)
(I could use pg_prewarm, but the table is much bigger than RAM, and
last_block value only has the newest record if data has never been
deleted. The oldest records regularly get deleted, and then the table is
vacuumed; thus, new records can be anywhere in the table.)
Thus, roll my own cache-loading statement.
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?
$ time psql -h foo bar -Xc "DO \$\$ BEGIN PERFORM * FROM mytbl ORDER BY id
DESC LIMIT 200000 ; END \$\$;"
DO
real 0m0.457s
user 0m0.005s
sys 0m0.004s
--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Christoph Moench-Tegeder | 2025-02-17 21:25:08 | Re: Loading the latest N rows into the cache seems way too fast. |
| Previous Message | Laurenz Albe | 2025-02-17 19:58:49 | Re: Clarification on Role Access Rights to Table Indexes |