# postgres 中 Index Scan 与 Index Only Scan 有何区别

Issue

欢迎在 Issue 中交流与讨论: Issue 348 (opens new window)

假设在 user 表简历索引 (name, age)

Index Scan 指查询中除利用索引外还有额外的查询条件,如 (name, age) 是索引,但是 sex 不是

select * from user where name = '张三' and age = 10 and sex = 'MALE'

Index Only Scan 指查询中可以全部利用索引,如 (name, age) 都是索引

select * from user where name = '张三' and age = 10
Last Updated: 1/17/2021, 2:02:56 PM