小编Thi*_*ell的帖子

Postgresql 9.5 BRIN 索引比预期慢得多

我有一个包含超过 1200 万行日志数据的表,并且已迁移到 Postgres 9.5 以利用新的 BRIN 索引,因为我有磁盘空间限制。鉴于我的日志行按日期自然排序,我假设我的情况是为了 BRIN 索引而定制的。

然而,我是从结果开始的。BRIN 比 btree 慢一个数量级以上。

原始Btree索引:

EXPLAIN ANALYZE SELECT COUNT(*) from logline where date BETWEEN '2016-01-15' and '2016-01-31';

 Aggregate  (cost=153488.38..153488.39 rows=1 width=0) (actual time=7672.508..7672.509 rows=1 loops=1)
   ->  Index Only Scan using logline_date on logline  (cost=0.43..145945.76 rows=3017046 width=0) (actual time=18.548..4084.455 
rows=2977593 loops=1)
         Index Cond: ((date >= '2016-01-15 00:00:00-05'::timestamp with time zone) AND (date <= '2016-01-31 00:00:00-05'::timestamp with time zone))
         Heap Fetches: 5809
 Planning time: 0.293 ms
 Execution time: 7672.562 ms
(6 rows) …
Run Code Online (Sandbox Code Playgroud)

index index-tuning postgresql-9.5

4
推荐指数
1
解决办法
3488
查看次数

标签 统计

index ×1

index-tuning ×1

postgresql-9.5 ×1