Re: Loading the latest N rows into the cache seems way too fast.
Christoph Moench-Tegeder <cmt@burggraben.net>
From: Christoph Moench-Tegeder <cmt@burggraben.net>
To: Ron Johnson <ronljohnsonjr@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Date: 2025-02-17T21:25:08Z
Lists: pgsql-general
## Ron Johnson (ronljohnsonjr@gmail.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