Postgis GIST指数 - 没有性能提升

时间:2018-06-06 11:56:03

标签: postgresql view postgis gist

我安装了Postgis的Postgres 9.5数据库。我创建了一个由大约200个表组成的物化视图。整个视图包含3,447,885条记录。每条记录都有一个几何类型的位置字段。当我在边界框中查询位置为ST_With的所有记录时,返回126,630行需要15.1秒。

我在字段上构建了一个GIST索引并运行查询,它仍然需要15.1才能返回126,630行。

示例查询:

SELECT ST_AsText (location) 
FROM myview 
WHERE ST_Within (location, ST_Geometry (....

我是否应该看到该大小的物化视图的显着性能提升?有什么我可以找到来表明性能问题的根源吗?

创建索引:

create index myview_location_gist on myview using gist (location);

解释分析:

'Bitmap Heap Scan on myview  (cost=130.56..11653.11 rows=1149 width=40) (actual time=18.377..564.760 rows=126330 loops=1)'
'  Recheck Cond: ('0103000020110F00000100000005000000D151D81DE90461C1831E458318835241D151D81DE90461C1D7A37045F81B53415C8FC23C79B860C1D7A37045F81B53415C8FC23C79B860C1831E458318835241D151D81DE90461C1831E458318835241'::geometry ~ location)'
'  Filter: _st_contains('0103000020110F00000100000005000000D151D81DE90461C1831E458318835241D151D81DE90461C1D7A37045F81B53415C8FC23C79B860C1D7A37045F81B53415C8FC23C79B860C1831E458318835241D151D81DE90461C1831E458318835241'::geometry, location)'
'  Rows Removed by Filter: 3'
'  Heap Blocks: exact=17361'
'  ->  Bitmap Index Scan on myview_location_gist  (cost=0.00..130.28 rows=3448 width=0) (actual time=15.923..15.923 rows=126333 loops=1)'
'        Index Cond: ('0103000020110F00000100000005000000D151D81DE90461C1831E458318835241D151D81DE90461C1D7A37045F81B53415C8FC23C79B860C1D7A37045F81B53415C8FC23C79B860C1831E458318835241D151D81DE90461C1831E458318835241'::geometry ~ location)'
'Planning time: 0.080 ms'
'Execution time: 570.068 ms'

0 个答案:

没有答案