相关疑难解决方法(0)

Postgres 9.5 外部表继承不使用索引

在 PostgreSQL 9.5.0 中,我有一个按月收集数据的分区表。尝试使用PostgreSQL新增的外表继承特性,将一个月的数据推送到另一台PostgreSQL服务器,结果得到了外表。当我从主服务器运行查询时,执行查询所需的时间比在我拥有外部表的服务器上长 7 倍。我没有通过网络传递大量数据,我的查询如下所示:

explain analyze
SELECT source, global_action, paid, organic, device, count(*) as count, sum(price) as sum
FROM "toys"
WHERE "toys"."container_id" = 857 AND (toys.created_at >= '2015-12-02 05:00:00.000000') AND
(toys.created_at <= '2015-12-30 04:59:59.999999') AND ("toys"."source" IS NOT NULL)
GROUP BY "toys"."source", "toys"."global_action", "toys"."paid", "toys"."organic", "toys"."device";

HashAggregate  (cost=1143634.94..1143649.10 rows=1133 width=15) (actual time=1556.894..1557.017 rows=372 loops=1)
   Group Key: toys.source, toys.global_action, toys.paid, toys.organic, toys.device
   ->  Append  (cost=0.00..1143585.38 rows=2832 width=15) (actual time=113.420..1507.373 rows=76593 loops=1)
         ->  Seq Scan on toys  (cost=0.00..0.00 rows=1 width=242) …
Run Code Online (Sandbox Code Playgroud)

postgresql performance inheritance foreign-data postgresql-9.5 postgresql-performance

2
推荐指数
1
解决办法
2298
查看次数