从postgresql数据库将最常扫描的表加载到缓存中。
pg_hotcache的Python项目详细描述
加载到缓存的限制是“有效缓存大小”的值。
重新启动服务器后使用是有意义的!
在使用之前,您需要以超级用户身份连接到数据库并添加 扩展名“pg_prewarm”(从9.4版起添加到PostgreSQL):
create extension pg_prewarm;
用法:
pg_hotcache [-?] [-h HOST] [-p PORT] [-U USERNAME] [-W PASSWORD] -d DBNAME
可选参数:
-?, --help show this help message and exit -h HOST, --host HOST database server host or socket directory (default: "local socket") -p PORT, --port PORT database server port (default: "5432") -U USERNAME, --username USERNAME database user name (default: "unix user") -W PASSWORD, --password PASSWORD force password prompt (should happen automatically) -d DBNAME, --dbname DBNAME database name for caching
示例:
sudo -u postgres pg_hotcache -d dbname pg_hotcache -h 127.0.0.1 -p 5432 -U username -d dbname