[postgis-devel] Faster ST_Intersection
Darafei "Komяpa" Praliaskouski
me at komzpa.net
Tue Oct 23 10:01:42 PDT 2018
Hi,
I have two polygonal layers to intersect and need to measure area of
intersections.
ST_Area(ST_Intersection(a.geom, b.geom)) works fine, but is rather slow.
Typical polygon on first side has <10 edges, on second 200..1000 edges.
What are my options to make it faster? Any ideas, links, experiences to
share are welcome.
For starters, this seems to work faster than vanilla ST_Intersection in my
case:
create or replace function clipped_st_intersection(geom1 geometry,
geom2 geometry)
returns geometry
as $$select ST_Intersection(
case
when ST_MemSize(geom1) > 160 then ST_ClipByBox2D(geom1, geom2)
else geom1 end, case
when ST_MemSize(geom2) > 160 then ST_ClipByBox2D(geom2, geom1)
else geom2 end)$$
language sql
immutable
strict
parallel safe;
--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20181023/ad2bf631/attachment.html>
More information about the postgis-devel
mailing list