【发布时间】:2023-03-05 17:34:02
【问题描述】:
给定一个存储表(~10k 记录)和一个时间表表(~200k 记录),我正在尝试创建和索引以供规划器使用,但到目前为止它忽略了它。
select * from stores str
inner join schedule sch on sch.store_id = str.store_id
where sch.open is true and sch.tables > 0
create index sch_open_tables_idx on schedule(open, tables) where open is true and tables > 0
有正确的方法吗?
【问题讨论】:
-
能否包含导致您认为索引被忽略以及在哪个查询中被忽略的日志/结果/测试?
-
请阅读postgresql-performance然后edit您的问题并提供缺失的信息。
-
至少,您不需要索引中的
open列(它将始终是true),但store_id可能会有所帮助(作为该索引中的第一列) . -- 另外,您可以在查询和索引中都使用where sch.open,is true不是必需的(但也不会受到伤害,可空性不会改变这里的情况;它只是感觉噪音)。
标签: postgresql indexing postgresql-9.4