>在任何给定的时间如何检查特定的表和索引的什么部分(%)缓存在内存中?
>在打开DB查询之前,预热缓存的最佳方法是什么?例如. “select *”强制进行顺序扫描(冷DB约15分钟),但后续响应时间仍然很差.有没有一种内置的方式来做,而不是通过查询?
谢谢,请随时通过电子邮件回复(info@shauldar.com))
– Shaul
关于您的第一点,contrib模块“pg_buffercache”允许您检查缓冲区缓存的内容.我喜欢定义这个:create or replace vIEw util.buffercache_hogs asselect case when pg_buffercache.reldatabase = 0 then '- global' when pg_buffercache.reldatabase <> (select pg_database.oID from pg_database where pg_database.datname = current_database()) then '- database ' || quote_literal(pg_database.datname) when pg_namespace.nspname = 'pg_catalog' then '- system catalogues' when pg_class.oID is null and pg_buffercache.relfilenode > 0 then '- unkNown file ' || pg_buffercache.relfilenode when pg_namespace.nspname = 'pg_toast' and pg_class.relname ~ '^pg_toast_[0-9]+$' then (substring(pg_class.relname,10)::oID)::regclass || ' TOAST'::text when pg_namespace.nspname = 'pg_toast' and pg_class.relname ~ '^pg_toast_[0-9]+_index$' then ((rtrim(substring(pg_class.relname,10),'_index'))::oID)::regclass || ' TOAST index' else pg_class.oID::regclass::text end as key,count(*) as buffers,sum(case when pg_buffercache.isdirty then 1 else 0 end) as dirty_buffers,round(count(*) / (SELECT pg_settings.setting FROM pg_settings WHERE pg_settings.name = 'shared_buffers')::numeric,4) as hog_factorfrom pg_buffercache left join pg_database on pg_database.oID = pg_buffercache.reldatabase left join pg_class on pg_class.relfilenode = pg_buffercache.relfilenode left join pg_namespace on pg_namespace.oID = pg_class.relnamespacegroup by 1order by 2 desc;
此外,“pageinspect”contrib模块允许您从一个关系访问特定的页面,所以我想你可以简单地循环访问所有页面的关系抓住他们?
select count(get_raw_page('information_schema.sql_features',n))from generate_serIEs(0,(select relpages-1 from pg_class where relname = 'sql_features')) n;
这将将所有的information_schema.sql_features加载到缓存中.
总结以上是内存溢出为你收集整理的Postgresql缓存(内存)性能如何预热缓存全部内容,希望文章能够帮你解决Postgresql缓存(内存)性能如何预热缓存所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)