Postgres 9.6 仅索引扫描
Postgres 9.6 Index-only scan
Postgres new release 9.6 - I have read the docs 关于仅索引扫描。
我知道 postgres 表的堆,我知道部分索引(或一般索引)是如何工作的。
我只是不明白 index-only 的好处。
问题
- 真正改变了什么?我们不是已经使用索引扫描了吗?
- 我应该如何以及何时使用它们以获得最佳收益?
非相关背景:
我正在处理具有 6B 行的表,在生产环境中有很多 INSERT
s 和 SELECT
s
Allow use of an index-only scan on a partial index when the index's WHERE clause references columns that are not indexed
(强调我的)
因此在 9.5 和之前的版本中,以下索引不能用于仅索引扫描:
create index on foo (col1, col2)
where col3 = 42;
因为 col3
不是索引列的一部分。这在 9.6
中已更改
Postgres new release 9.6 - I have read the docs 关于仅索引扫描。 我知道 postgres 表的堆,我知道部分索引(或一般索引)是如何工作的。 我只是不明白 index-only 的好处。
问题
- 真正改变了什么?我们不是已经使用索引扫描了吗?
- 我应该如何以及何时使用它们以获得最佳收益?
非相关背景:
我正在处理具有 6B 行的表,在生产环境中有很多 INSERT
s 和 SELECT
s
Allow use of an index-only scan on a partial index when the index's WHERE clause references columns that are not indexed
(强调我的)
因此在 9.5 和之前的版本中,以下索引不能用于仅索引扫描:
create index on foo (col1, col2)
where col3 = 42;
因为 col3
不是索引列的一部分。这在 9.6