标签

PostgreSQL , st_contains , st_within , 空间包含 , 空间bound box , GiST索引 , 空间索引结构 , IO放大 , BOUND BOX放大


背景

点面判断、按面圈选点或其他对象,是GIS几何应用中非常典型的需求。

在PostgreSQL中通过建立GiST索引可以加速这类判断,然而,建立索引就够了吗?

很多时候建立索引是不够的,性能没有到达巅峰,如果要更低的延迟,更少的CPU开销,还有什么优化手段呢?

实际上我以前写过一篇类似的文章,讲的是BTree索引访问的优化,当数据存放与索引顺序的线性相关性很差时,引入了一个问题,访问时IO放大:

《索引顺序扫描引发的堆扫描IO放大背后的统计学原理与解决办法 - PostgreSQL index scan enlarge heap page scans when index and column correlation small.》

原理和解决办法上面的文档已经讲得很清楚了。对于空间索引也有类似的问题和优化方法。但是首先你需要了解空间索引的构造:

《通过空间思想理解GiST索引的构造》

然后你可以通过空间聚集,来降低空间扫描的IO。

《PostgreSQL 黑科技 - 空间聚集存储》

下面以一个搜索为例,讲解空间包含搜索的优化方法:

在表中有1000万空间对象数据,查询某个多边形覆盖到的空间对象。这个查询有一个特点,这个多边形是一个长条条的多边形,包含这个多边形的BOUND BOX是比较大的。

构建这个多边形的方法

postgres=# select st_setsrid(st_makepolygon(ST_GeomFromText('LINESTRING(0 0,1 0,1 2.5,6 2.5,6 4,7 4,7 5,5 5,5 3,0 3,0 0)')), 4326);  st_setsrid
----------------------------  0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000
(1 row)

优化手段1 - 空间聚集

1、建表

postgres=# create table e(id int8, pos geometry);
CREATE TABLE

2、写入空间测试数据(1000万个随机点,覆盖 +-50 的经纬度区间)

postgres=# insert into e select id, st_setsrid(st_makepoint(50-random()*100, 50-random()*100), 4326) from generate_series(1,10000000) t(id);
INSERT 0 10000000

3、创建空间索引

postgres=# create index idx_e on e using gist(pos);
CREATE INDEX

4、查询满足这个多边形的BOUND BOX覆盖的对象的BOUND BOX条件的对象。

postgres=# explain (analyze,verbose,timing,costs,buffers) select * from e where pos @ st_setsrid(st_makepolygon(ST_GeomFromText('LINESTRING(0 0,1 0,1 2.5,6 2.5,6 4,7 4,7 5,5 5,5 3,0 3,0 0)')), 4326);  QUERY PLAN
-----------------------  Index Scan using idx_e on public.e  (cost=0.42..12526.72 rows=10000 width=40) (actual time=0.091..39.449 rows=35081 loops=1)  Output: id, pos  Index Cond: (e.pos @ '0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry)  Buffers: shared hit=35323  Planning time: 0.108 ms  Execution time: 41.222 ms
(6 rows)

搜索了35323个数据块,返回了35081条记录。

5、查询被这个多边形包含的对象。

postgres=# explain (analyze,verbose,timing,costs,buffers) select * from e where st_contains(st_setsrid(st_makepolygon(ST_GeomFromText('LINESTRING(0 0,1 0,1 2.5,6 2.5,6 4,7 4,7 5,5 5,5 3,0 3,0 0)')), 4326), pos);    QUERY PLAN
-----------------------  Index Scan using idx_e on public.e  (cost=0.42..15026.72 rows=3333 width=40) (actual time=0.077..49.015 rows=8491 loops=1)  Output: id, pos  Index Cond: ('0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry ~ e.pos)  Filter: _st_contains('0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry, e.pos)  Rows Removed by Filter: 26590  Buffers: shared hit=35323  Planning time: 0.085 ms  Execution time: 49.460 ms
(8 rows)

搜索了35323个数据块,搜索了35081条记录,返回了8491条记录,过滤了26590条不满足条件的记录。

5和4的查询差异是BOUND BOX包含、实际的轮廓包含。索引的基础是bound box。在以下文档中我们也可以学习到这个原理。

《通过空间思想理解GiST索引的构造》

我们看到,复合条件的记录并不多,但是搜索了很多数据块,通过空间聚集可以减少数据块的扫描。

6、创建另一张表,按空间聚集,调整数据存储顺序。并建立空间索引。

postgres=# create table f(like e);
CREATE TABLE  postgres=# insert into f select * from e order by st_geohash(pos,15);
INSERT 0 10000000  postgres=# create index idx_f on f using gist(pos);
CREATE INDEX

7、优化后:

查询满足这个多边形的BOUND BOX覆盖的对象的BOUND BOX条件的对象。从扫描35323个数据块降低到了访问1648个数据块。质的飞跃。

postgres=# explain (analyze,verbose,timing,costs,buffers) select * from f where pos @ st_setsrid(st_makepolygon(ST_GeomFromText('LINESTRING(0 0,1 0,1 2.5,6 2.5,6 4,7 4,7 5,5 5,5 3,0 3,0 0)')), 4326);  QUERY PLAN
-----------------------  Index Scan using idx_f on public.f  (cost=0.42..12526.72 rows=10000 width=40) (actual time=0.081..9.702 rows=35081 loops=1)  Output: id, pos  Index Cond: (f.pos @ '0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry)  Buffers: shared hit=1648  Planning time: 0.096 ms  Execution time: 11.404 ms
(6 rows)

8、优化后:

查询被这个多边形包含的对象。从扫描35323个数据块降低到了访问1648个数据块。质的飞跃。

postgres=# explain (analyze,verbose,timing,costs,buffers) select * from f where st_contains(st_setsrid(st_makepolygon(ST_GeomFromText('LINESTRING(0 0,1 0,1 2.5,6 2.5,6 4,7 4,7 5,5 5,5 3,0 3,0 0)')), 4326), pos);  QUERY PLAN
-----------------------  Index Scan using idx_f on public.f  (cost=0.42..15026.72 rows=3333 width=40) (actual time=1.216..32.398 rows=8491 loops=1)  Output: id, pos  Index Cond: ('0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry ~ f.pos)  Filter: _st_contains('0103000020E6100000010000000B00000000000000000000000000000000000000000000000000F03F0000000000000000000000000000F03F000000000000044000000000000018400000000000000440000000000000184000000000000010400000000000001C4000000000000010400000000000001C40000000000000144000000000000014400000000000001440000000000000144000000000000008400000000000000000000000000000084000000000000000000000000000000000'::geometry, f.pos)  Rows Removed by Filter: 26590  Buffers: shared hit=1648  Planning time: 0.101 ms  Execution time: 32.837 ms
(8 rows)

使用空间聚集,从扫描35323个数据块降低到了访问1648个数据块。质的飞跃。

优化手段2 - 空间分裂查询

空间聚集的优化手段,解决了IO放大的问题,另一个优化点和空间索引的结构有关,是BOUND BOX放大的问题。

从本文的例子中,我们也看到了,空间索引实际上是针对bound box的,所以在有效面积占比较低时,可能圈选到多数无效数据,导致IO和CPU同时放大,我们就来解决它。

下图虚线部分包含的区间就是这个长条条的BOUND BOX。目前数据库在使用GiST索引查询满足这个多边形包含的POS的条件时,会将落在这个BOUND BOX中的对象都弄出来。

优化思路:

将这个多边形,拆成4个BOX,完全杜绝bound box放大的问题。

explain (analyze,verbose,timing,costs,buffers) select * from f where   st_contains(st_setsrid(st_makebox2d(st_makepoint(0,0), st_makepoint(1,3)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(1,2.5), st_makepoint(5,3)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(5,2.5), st_makepoint(6,5)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(6,4), st_makepoint(7,5)), 4326), pos);  explain (analyze,verbose,timing,costs,buffers) select * from f where   pos @ st_setsrid(st_makebox2d(st_makepoint(0,0), st_makepoint(1,3)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(1,2.5), st_makepoint(5,3)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(5,2.5), st_makepoint(6,5)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(6,4), st_makepoint(7,5)), 4326);

1、组合1和2的优化手段后:

查询满足这个多边形的BOUND BOX覆盖的对象的BOUND BOX条件的对象。从扫描1648个数据块降低到了访问243个数据块。质的飞跃。

explain (analyze,verbose,timing,costs,buffers) select * from f where   pos @ st_setsrid(st_makebox2d(st_makepoint(0,0), st_makepoint(1,3)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(1,2.5), st_makepoint(5,3)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(5,2.5), st_makepoint(6,5)), 4326)  or  pos @ st_setsrid(st_makebox2d(st_makepoint(6,4), st_makepoint(7,5)), 4326);  QUERY PLAN
-----------------------  Bitmap Heap Scan on public.f  (cost=10000000690.01..10000037405.46 rows=39940 width=40) (actual time=1.502..2.329 rows=8491 loops=1)  Output: id, pos  Recheck Cond: ((f.pos @ '0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry) OR (f.pos @ '0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry) OR (f.pos @ '0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry) OR (f.pos @ '0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry))  Heap Blocks: exact=119  Buffers: shared hit=243  ->  BitmapOr  (cost=690.01..690.01 rows=40000 width=0) (actual time=1.483..1.483 rows=0 loops=1)  Buffers: shared hit=124  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.461..0.461 rows=3077 loops=1)  Index Cond: (f.pos @ '0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry)  Buffers: shared hit=37  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.423..0.423 rows=1991 loops=1)  Index Cond: (f.pos @ '0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry)  Buffers: shared hit=33  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.366..0.366 rows=2435 loops=1)  Index Cond: (f.pos @ '0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry)  Buffers: shared hit=31  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.232..0.232 rows=988 loops=1)  Index Cond: (f.pos @ '0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry)  Buffers: shared hit=23  Planning time: 0.104 ms  Execution time: 2.751 ms
(21 rows)

2、组合1和2的优化手段后:

查询被这个多边形包含的对象。从扫描1648个数据块降低到了访问243个数据块。质的飞跃。

postgres=# explain (analyze,verbose,timing,costs,buffers) select * from f where   st_contains(st_setsrid(st_makebox2d(st_makepoint(0,0), st_makepoint(1,3)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(1,2.5), st_makepoint(5,3)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(5,2.5), st_makepoint(6,5)), 4326), pos)  or  st_contains(st_setsrid(st_makebox2d(st_makepoint(6,4), st_makepoint(7,5)), 4326), pos);  QUERY PLAN
--------------------------------------------  Bitmap Heap Scan on public.f  (cost=663.40..77378.85 rows=13327 width=40) (actual time=1.496..11.038 rows=8491 loops=1)  Output: id, pos  Recheck Cond: (('0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry ~ f.pos) OR  ('0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry ~ f.pos) OR ('0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry ~ f.pos) OR ('0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry ~ f.pos))  Filter: ((('0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry ~ f.pos) AND _st_contains('0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry, f.pos)) OR (('0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry ~ f.pos) AND _st_contains('0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry, f.pos)) OR (('0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry ~ f.pos) AND _st_contains('0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry, f.pos)) OR (('0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry ~ f.pos) AND _st_contains('0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry, f.pos)))  Heap Blocks: exact=119  Buffers: shared hit=243  ->  BitmapOr  (cost=663.40..663.40 rows=40000 width=0) (actual time=1.472..1.472 rows=0 loops=1)  Buffers: shared hit=124  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.436..0.436 rows=3077 loops=1)  Index Cond: ('0103000020E610000001000000050000000000000000000000000000000000000000000000000000000000000000000840000000000000F03F0000000000000840000000000000F03F000000000000000000000000000000000000000000000000'::geometry ~ f.pos)  Buffers: shared hit=37  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.438..0.438 rows=1991 loops=1)  Index Cond: ('0103000020E61000000100000005000000000000000000F03F0000000000000440000000000000F03F00000000000008400000000000001440000000000000084000000000000014400000000000000440000000000000F03F0000000000000440'::geometry ~ f.pos)  Buffers: shared hit=33  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.365..0.365 rows=2435 loops=1)  Index Cond: ('0103000020E610000001000000050000000000000000001440000000000000044000000000000014400000000000001440000000000000184000000000000014400000000000001840000000000000044000000000000014400000000000000440'::geometry ~ f.pos)  Buffers: shared hit=31  ->  Bitmap Index Scan on idx_f  (cost=0.00..162.52 rows=10000 width=0) (actual time=0.234..0.234 rows=988 loops=1)  Index Cond: ('0103000020E6100000010000000500000000000000000018400000000000001040000000000000184000000000000014400000000000001C4000000000000014400000000000001C40000000000000104000000000000018400000000000001040'::geometry ~ f.pos)  Buffers: shared hit=23  Planning time: 0.163 ms  Execution time: 11.497 ms
(22 rows)

优化手段2,将长条条的polygon拆分成多个小的box,将大的bound box消除,搜索的BLOCK再次降低到243。质的飞跃。

将两个手段合并起来用,起到了双剑合璧的效果。

st_split 切分对象

PostGIS提供了切分对象的方法。

http://postgis.net/docs/manual-2.4/ST_Split.html

-- this creates a geometry collection consisting of the 2 halves of the polygon
-- this is similar to the example we demonstrated in ST_BuildArea
SELECT ST_Split(circle, line)
FROM (SELECT  ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 190)) As line,  ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) As circle) As foo;  -- result --  GEOMETRYCOLLECTION(POLYGON((150 90,149.039264020162 80.2454838991936,146.193976625564 70.8658283817455,...), POLYGON(...)))  -- To convert to individual polygons, you can use ST_Dump or ST_GeometryN
SELECT ST_AsText((ST_Dump(ST_Split(circle, line))).geom) As wkt
FROM (SELECT  ST_MakeLine(ST_MakePoint(10, 10),ST_MakePoint(190, 190)) As line,  ST_Buffer(ST_GeomFromText('POINT(100 90)'), 50) As circle) As foo;  -- result --
wkt
---------------
POLYGON((150 90,149.039264020162 80.2454838991936,...))
POLYGON((60.1371179574584 60.1371179574584,58.4265193848728 62.2214883490198,53.8060233744357 ...))

SELECT ST_AsText(ST_Split(mline, pt)) As wktcut  FROM (SELECT  ST_GeomFromText('MULTILINESTRING((10 10, 190 190), (15 15, 30 30, 100 90))') As mline,  ST_Point(30,30) As pt) As foo;  wktcut
------
GEOMETRYCOLLECTION(  LINESTRING(10 10,30 30),  LINESTRING(30 30,190 190),  LINESTRING(15 15,30 30),  LINESTRING(30 30,100 90)
)

我后面写了一篇文档来简化SPLIT:

《PostgreSQL 空间切割(st_split)功能扩展 - 空间对象网格化》

st_snap

http://postgis.net/docs/manual-2.4/ST_Snap.html

@, ~ 与 ST_Contains, ST_Within的区别

@, ~ 与 ST_Contains, ST_Within都是对象包含的操作符或函数,他们有什么区别呢?

@

A @ B

Returns TRUE if A's bounding box is contained by B's.

~

与 @ 含义相反。

A ~ B

Returns TRUE if A's bounding box contains B's.

ST_Contains

ST_Contains(A, B)

Returns true if and only if no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A.

ST_Within

与 ST_Contains 含义相反。

ST_Within(A, B)

Returns true if the geometry A is completely inside geometry B

区别

@ 和 ~的操作并不是直接针对几何对象,而是针对A和B的bound box的,也就是说包含对象的左下和右上的点组成的BOX。  ST_Within和ST_Contains是针对几何对象的,但是从GiST索引搜索角度来看,是需要先用BOUND BOX去搜索,再通过CPU进行计算来判断的。

例子

A @ Polygon,返回真  B @ Polygon,返回真  C @ Polygon,返回真  ST_Contains(Polygon, A),返回假  ST_Contains(Polygon, B),返回真  ST_Contains(Polygon, C),返回假

小结

空间搜索的两个可以优化的点,原理如下:

1、空间数据在存储时乱序存放,导致搜索一批数据时扫描的数据块很多。(点查感觉不到这个问题。)

2、PostGIS的GiST空间索引,采用了BOUND BOX作为KEY,搜索时也是使用对象的BOUND BOX进行搜索,因此当对象是长条条时,可能造成大量的BOUND BOX空洞,放大了扫描范围(对st_contains, st_within来说),增加了CPU过滤的开销。

优化手段1:空间聚集,解决IO放大问题。

优化手段2:对输入条件(长条条的多边形)进行SPLIT,降低BOUND BOX放大引入的扫描范围(对st_contains, st_within来说)放大的问题。

数据量:1000万。

点面判断(长条形多边形,或者离散多个多边形对象覆盖的空间对象)。

优化前 优化1(空间聚集) 优化1,2(SPLIT多边形)
访问35323块 访问1648块 访问243块
过滤26590条 过滤26590条 过滤0条

参考

《通过空间思想理解GiST索引的构造》

《PostgreSQL 黑科技 - 空间聚集存储》

《Greenplum 空间(GIS)数据检索 b-tree & GiST 索引实践 - 阿里云HybridDB for PostgreSQL最佳实践》

《PostGIS空间索引(GiST、BRIN、R-Tree)选择、优化 - 阿里云RDS PostgreSQL最佳实践》

《PostGIS 空间数据学习建议》

《PostgreSQL 空间切割(st_split)功能扩展 - 空间对象网格化》

http://postgis.net/docs/manual-2.4/ST_Within.html

http://postgis.net/docs/manual-2.4/ST_Contains.html

http://postgis.net/docs/manual-2.4/ST_Geometry_Contained.html

http://postgis.net/docs/manual-2.4/ST_Geometry_Contain.html

http://postgis.net/docs/manual-2.4/ST_Split.html

http://postgis.net/docs/manual-2.4/ST_Snap.html

PostgreSQL 空间st_contains,st_within空间包含搜索优化 - 降IO和降CPU(bound box)相关推荐

  1. PostgreSQL 如何查找TOP SQL (例如IO消耗最高的SQL) (包含SQL优化内容)

    目录 背景 一.安装pg_stat_statements 二.加载pg_stat_statements模块 三.配置pg_stat_statements采样参数 四.创建pg_stat_stateme ...

  2. HTAP数据库 PostgreSQL 场景与性能测试之 6 - (OLTP) 空间应用 - KNN查询(搜索附近对象,由近到远排序输出)...

    标签 PostgreSQL , HTAP , OLTP , OLAP , 场景与性能测试 背景 PostgreSQL是一个历史悠久的数据库,历史可以追溯到1973年,最早由2014计算机图灵奖得主,关 ...

  3. PostgreSQL数据库、表空间、角色及用户

    一.创建数据库 1.通过pgAdmin创建数据库TestDb1: 打开数据库TestDb1看到建库脚本: 在目录--PostgreSQL(pg_catalog)--数据表--pg_database中可 ...

  4. PostgreSQL主库创建表空间导致备库宕机

    PostgreSQL主库创建表空间导致备库宕机 PG版本:11.7 最后编辑时间:2022年1月23日00:17:06 主库创建表空间 [postgres@rhel6wcb /]$ mkdir -p ...

  5. mysql空间计算_MySQL 空间计算 空间查询

    一.前言 MySQL实施了OGC建议的具有Geometry类型的SQL环境的一个子集.该术语指的是用一组集合类型扩展的环境.具有几何值的SQL列是作为拥有集合类型的列实施的.该规范描述了SQL几何类型 ...

  6. SEO搜索 优化经验

    我不是SEO从业者亦不是搜索引擎排名工程师,我尽量保证提到策略有效且合乎规则的,如有谬误,请略过或指正,我本人不推荐一些所谓的"黑帽"策略,因为能欺骗搜索引擎一时却不能长久,所以做 ...

  7. 浅谈数据挖掘——频繁模式、序列挖掘与搜索优化算法

    本系列将从下面几方面谈谈最近的一点点收获 令声明:本文主要是对我找到的一个莫名其妙国外英文pdf文件的学习与解读,因为我也没有找到他的出处(也没作者也没学校),所以我仅以此段文字向这个未知的作者致敬. ...

  8. outlook搜索栏跑到上面去了_长春企业网站搜索优化如何做

    如何做企业l31b10网站搜索优化长春,SEO排名,它是指搜索引擎优化关键词排名.而影响到seo排名的因素有很多,比如说域名注册的时间,服务器的空间速度和稳定性,或者像是网站整体的结构,网站的内容等等 ...

  9. 基于windows PE文件的恶意代码分析;使用SystemInternal工具与内核调试器研究windows用户空间与内核空间...

    基于windows PE文件的恶意代码分析:使用SystemInternal工具与内核调试器研究windows用户空间与内核空间 ******************** 既然本篇的主角是PE文件,那 ...

最新文章

  1. 电荷泵式开关电源的基本电路
  2. MASK-RCNN学习一:(数据集/原理介绍)
  3. tinyid 教程_tinyid
  4. 程序员面试金典 - 面试题 17.19. 消失的两个数字(数学/位运算)
  5. python开发框架大全_最受欢迎 Top 12 Python 开源框架,你都用过吗?
  6. 优化技巧一、UITableView加载图片
  7. 一个发散动画的菜单控件(主要记录控件x,y坐标的运动状况)
  8. TiledMap的使用
  9. springboot中Word转PDF技巧
  10. YUV与RGB互转各种公式
  11. 安川焊接机器人做圆弧运动编程_安川MOTOMAN工业机器人编程与操作(6)
  12. 坚果云+Markor+Typora实现多平台Markdown协同编辑
  13. vue PC项目实现 支付宝支付(跳转至支付界面)
  14. 跨界打劫!中医保健店用一招免费洗车,快速引流进店,月赚20万
  15. excel公式不执行。原因是设置问题:公式->计算选项->手动
  16. 手机通讯录系统(三层架构+JDBC+MySQL)
  17. 计算机网络常用知识总结!
  18. springboot整合Hystrix 熔断器
  19. 云原生|Qunar 云原生容器化落地实践
  20. spark分布式矩阵采坑记

热门文章

  1. JavaSocket编程之Netty框架线程模型
  2. Qt数据库应用17-通用数据库请求
  3. android 语言的设置与获取
  4. 用python写atm自动取款_Python实现atm机的功能
  5. 攻击微软、三星等大型企业的黑客组织LAPSUS$成员被逮捕
  6. 研报复现初探—华泰金工人工智能选股系列之boosting模型
  7. C语言在学习编程的作用并简单了解一下C语言
  8. 先行一步,7 大技术创新和突破,阿里云把 Serverless 领域的这些难题都给解了
  9. ARP局域网断网攻击原理分析及演示
  10. 快速理解数据库超键,候选键,主键