以下对外部的查询在 320 万行上执行大约需要 5 秒:
SELECT x."IncidentTypeCode", COUNT(x."IncidentTypeCode")
FROM "IntterraNearRealTimeUnitReflexes300sForeign" x
WHERE x."IncidentDateTime" >= '05/01/2016'
GROUP BY x."IncidentTypeCode"
ORDER BY 1;
Run Code Online (Sandbox Code Playgroud)
当我在普通表上执行相同的查询时,它会在 0.6 秒内返回。执行计划完全不同:
SELECT x."IncidentTypeCode", COUNT(x."IncidentTypeCode")
FROM "IntterraNearRealTimeUnitReflexes300sForeign" x
WHERE x."IncidentDateTime" >= '05/01/2016'
GROUP BY x."IncidentTypeCode"
ORDER BY 1;
Run Code Online (Sandbox Code Playgroud)
Sort (cost=226861.20..226861.21 rows=4 width=4) (actual time=646.447..646.448 rows=7 loops=1)
Sort Key: "IncidentTypeCode"
Sort Method: quicksort Memory: 25kB
-> HashAggregate (cost=226861.12..226861.16 rows=4 width=4) (actual time=646.433..646.434 rows=7 loops=1)
Group Key: "IncidentTypeCode"
-> Bitmap Heap Scan on "IntterraNearRealTimeUnitReflexes300s" x (cost=10597.63..223318.41 rows=708542 width=4) …
Run Code Online (Sandbox Code Playgroud) postgresql performance postgresql-fdw postgresql-9.5 query-performance
我正在尝试对一些外部空间表执行查询,这比在普通空间表上运行的时间长几个数量级,因为没有使用索引。
索引似乎正在处理非空间查询。
这是应该工作的东西还是不受支持?
postgresql performance index spatial postgis query-performance