微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在postgresql中解释(缓冲,分析)

我是 postgresql的新手,我试着理解 explain(缓冲区,分析)指令.我有一个查询,我使用explain(buffers,analyze)执行它.

第一次执行它时性能比第二次差.此外,第一次在’hit’旁边获得’read’参数,而第二次’read’不存在.

有人可以帮我理解吗?

解决方法

第一次选择,页面变热 – 它们被加载到缓存,一旦它们在RAM中 – 所有下一个选择将更快(RAM速度更高).

因此缓冲区显示读取,当页面不在缓存中时,cos postgres读取它们,并且当它们变热时不读取,因此缓存被命中…

使用docs更新:

BUFFERS

Include @R_425_4045@ion on buffer usage. Specifically,include the
number of shared blocks hit,read,dirtied,and written,the number of
local blocks hit,and the number of temp
blocks read and written. A hit means that a read was avoided because
the block was found already in cache when needed. Shared blocks
contain data from regular tables and indexes; local blocks contain
data from temporary tables and indexes; while temp blocks contain
short-term working data used in sorts,hashes,Materialize plan nodes,
and similar cases. The number of blocks dirtied indicates the number
of prevIoUsly unmodified blocks that were changed by this query; while
the number of blocks written indicates the number of
prevIoUsly-dirtied blocks evicted from cache by this backend during
query processing. The number of blocks shown for an upper-level node
includes those used by all its child nodes. In text format,only
non-zero values are printed. This parameter may only be used when
ANALYZE is also enabled. It defaults to FALSE.

令人惊讶的是缓冲区here并不多.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐