sql - 在 postgresql 中解释(缓冲区、分析)

标签 sql postgresql instructions

我是 postgresql 的新手,我试图理解 explain (缓冲区,分析)指令。我有一个查询,我使用解释(缓冲区、分析)执行它。

我第一次执行它的性能比第二次差。此外,第一次我在“命中”旁边得到一个“读取”参数,而第二次“读取”不存在。

谁能帮我理解一下?

最佳答案

第一次选择时,页面变暖 - 它们被加载到缓存中,一旦它们在 RAM 中 - 所有下一次选择都会更快(RAM 速度更高)。

相应地,buffers 显示读取,当页面不在缓存中时,cos postgres 读取它们,而当它们处于热状态时不读取,因此缓存被命中...

更新 docs :

BUFFERS

Include information on buffer usage. Specifically, include the number of shared blocks hit, read, dirtied, and written, the number of local blocks hit, read, dirtied, and written, 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 .

关于sql - 在 postgresql 中解释(缓冲区、分析),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43887275/

相关文章:

mysql - 使用 parent_id 求和并分组

executable - 有运行时代码修改的聪明案例吗?

java - Java 指令包

linux - 如何使用 Intel Pin 工具生成分支列表?

MySQL - 通过给出表名称显示 CREATE TABLE 结果

python - 如何在 Flask-SQLAlchemy 应用程序中执行原始 SQL

java - 如何检查违反了哪些约束?

sql - 选择 id_field WHERE max(date_field) < 'some date'

ruby-on-rails - 按日期排序,然后按 ID,而不是按第二列排序

postgresql - 无法插入日期(Y-m-d H :i:s) in Postgres "timestamp"