Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
351 views
in Technique[技术] by (71.8m points)

postgresql - Postgres pg_prewarm to keep table in buffer gives 0 after dropping table

I followed the steps as outlined in this tutorial to use pg_prewarm extention for pre-warming the buffer cache in PostgreSQL:

https://ismailyenigul.medium.com/pg-prewarm-extention-to-pre-warming-the-buffer-cache-in-postgresql-7e033b9a386d

The first time I ran it, I got 1 as the result:

mydb=> SELECT pg_prewarm('useraccount');
 pg_prewarm 
------------
          1

After that I had to drop the table and recreate it. Since then, when I run the same command, I get 0 as the result always. I am not sure if that's expected or if I am missing something?

mydb=> SELECT pg_prewarm('useraccount');
 pg_prewarm 
------------
          0
question from:https://stackoverflow.com/questions/65883517/postgres-pg-prewarm-to-keep-table-in-buffer-gives-0-after-dropping-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The function comment in contrib/pg_prewarm/pg_prewarm.c says:

 * [...] The
 * return value is the number of blocks successfully prewarmed.

So the first time, there was 1 block in the table. After dropping and re-creating the table, it is empty, so 0 blocks are cached.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...