[postgis-tickets] [PostGIS] #4675: Implement topology.GetRingEdges in C
PostGIS
trac at osgeo.org
Fri May 8 09:27:42 PDT 2020
#4675: Implement topology.GetRingEdges in C
--------------------------+---------------------------
Reporter: strk | Owner: strk
Type: enhancement | Status: closed
Priority: medium | Milestone: PostGIS 3.1.0
Component: topology | Version: 3.0.x
Resolution: fixed | Keywords:
--------------------------+---------------------------
Comment (by strk):
For the record, the C version is 21% faster.
Tested with following input:
{{{
SELECT DropTopology('city_data');
\i topology/test/load_topology.sql
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
10, 10)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
11, 10)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
12, 10)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
13, 10)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
16, 10)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
10, 11)) from city_data.face where face_id >0;
select
topology.TopoGeo_AddPolygon('city_data',ST_Translate(ST_GetFaceGeometry('city_data',face_id),
10, -20)) from city_data.face where face_id >0;
}}}
And following query:
{{{
explain (analyze, buffers)
select count(*) from (
select edge_id, (getRingEdges('city_data', edge_id)).*
from city_data.edge
) foo;
}}}
Results in following plans:
PLPGSQL:
{{{
Aggregate (cost=5040787.79..5040787.79 rows=1 width=8) (actual
time=2646.457..2646.457 rows=1 loops=1)
Buffers: shared hit=804888
-> Result (cost=0.29..4921412.79 rows=9550000 width=12) (actual
time=54.797..2634.831 rows=258613 loops=1)
Buffers: shared hit=804888
-> ProjectSet (cost=0.29..50912.79 rows=9550000 width=32)
(actual time=54.792..2609.541 rows=258613 loops=1)
Buffers: shared hit=804888
-> Index Only Scan using edge_data_pkey on edge_data
(cost=0.29..727.53 rows=9550 width=4) (actual time=0.024..3.815 rows=9550
loops=1)
Heap Fetches: 0
Buffers: shared hit=146
Planning Time: 0.319 ms
JIT:
Functions: 6
Options: Inlining true, Optimization true, Expressions true, Deforming
true
Timing: Generation 0.362 ms, Inlining 31.182 ms, Optimization 11.497 ms,
Emission 11.008 ms, Total 54.049 ms
Execution Time: 2674.792 ms
}}}
C:
{{{
Aggregate (cost=311174.16..311174.17 rows=1 width=8) (actual
time=2072.915..2072.915 rows=1 loops=1)
Buffers: shared hit=824179
-> Result (cost=0.29..191799.16 rows=9550000 width=12) (actual
time=19.584..2059.942 rows=258613 loops=1)
Buffers: shared hit=824179
-> ProjectSet (cost=0.29..48549.16 rows=9550000 width=32)
(actual time=19.576..2034.256 rows=258613 loops=1)
Buffers: shared hit=824179
-> Index Only Scan using edge_data_pkey on edge_data
(cost=0.29..727.53 rows=9550 width=4) (actual time=0.034..3.536 rows=9550
loops=1)
Heap Fetches: 0
Buffers: shared hit=146
Planning Time: 0.312 ms
JIT:
Functions: 6
Options: Inlining false, Optimization false, Expressions true, Deforming
true
Timing: Generation 0.443 ms, Inlining 0.000 ms, Optimization 0.144 ms,
Emission 2.760 ms, Total 3.346 ms
Execution Time: 2107.907 ms
}}}
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/4675#comment:3>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list