【发布时间】:2015-10-18 07:38:24
【问题描述】:
这是我在 Postgres 9.4 中的表格(实际上是物化视图):
Materialized view "public.vw_presentation_summary"
Column | Type | Modifiers
-------------------+-----------------------+-----------
processing_date | date |
presentation_code | character varying(15) |
items | numeric |
cost | double precision |
Indexes:
"vw_idx_presentation_summary" btree (presentation_code)
我刚刚运行了VACUUM ANALYZE vw_presentation_summary,所以查询规划器应该是最新的。
现在,如果我运行 explain (analyse, buffers) select * from vw_presentation_summary where presentation_code LIKE '0205051I0BB%',这就是我所看到的:
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------
Seq Scan on vw_presentation_summary (cost=0.00..23202.16 rows=182 width=32) (actual time=0.440..222.383 rows=224 loops=1)
Filter: ((presentation_code)::text ~~ '0205051I0BB%'::text)
Rows Removed by Filter: 1115229
Buffers: shared hit=9259
Planning time: 0.760 ms
Execution time: 222.524 ms
(6 rows)
解释链接:http://explain.depesz.com/s/nTL4
为什么这是运行 Seq Scan 而不是索引查找?
【问题讨论】:
标签: postgresql