我试图推断 Postgres 部分索引是如何存储在 Postgres 中的。假设我创建一个这样的索引
CREATE INDEX orders_unbilled_index ON orders (order_nr)
WHERE billed is not true
为了快速运行查询
SELECT *
FROM orders
WHERE billed is not true AND order_nr > 1000000
Postgres 显然存储了一个建立在条件表达式定义order_nr
的表子集上的索引。但是,我有几个与此相关的问题:orders
billed is not true
- Postgres 是否在内部存储另一个索引
billed is not true
以快速找到与部分索引关联的行? - 如果 (1) 不是这种情况,如果我在 上创建单独的索引,是否会使上面的查询运行得更快
billed is not true
?(假设一个大表和几行billed is true
)
编辑:由于布尔索引很少使用,我基于文档的示例查询并不是最好的,但请在任何条件表达式的上下文中考虑我的问题。