PostGIS धीमा ST_Intersection

Sep 25 2020

मैं कोशिश कर रहा हूँ कि एक सीधी रेखा और कुछ समोच्च रेखाओं के बीच अंतर हो। नीचे SQL का उपयोग:

DROP TABLE IF EXISTS v_line;
SELECT st_geomfromtext('linestring(103.492217095662 30.9300260311043,103.494817217263 30.9200436767033)',4326) as geom INTO v_line;
SELECT a.gid,a.height, ST_AsText(ST_Intersection(b.geom, a.geom)) 
FROM contour_cb9eba as a,v_line as b 
WHERE ST_Intersects(b.geom,a.geom);

लेकिन क्वेरी को खत्म होने में दसियों सेकंड लगते हैं। मैंने postgresql को ट्यून किया है, मदद नहीं करता है। मैंने समोच्च तालिका पर सूचकांक बनाया है, मदद नहीं करता है। व्याख्या नीचे है:

Nested Loop  (cost=0.14..665.47 rows=37 width=44)
  ->  Seq Scan on v_line b  (cost=0.00..23.60 rows=1360 width=32)
  ->  Index Scan using contour_cb9eba_geom_idx on contour_cb9eba a  (cost=0.14..0.41 rows=1 width=746174)
        Index Cond: (b.geom && geom)
        Filter: _st_intersects(b.geom, geom)

व्याख्या विश्लेषण नीचे है:

Nested Loop  (cost=0.14..665.47 rows=37 width=44) (actual time=245.343..4629.091 rows=23 loops=1)
  ->  Seq Scan on v_line b  (cost=0.00..23.60 rows=1360 width=32) (actual time=0.011..0.013 rows=1 loops=1)
  ->  Index Scan using contour_cb9eba_geom_idx on contour_cb9eba a  (cost=0.14..0.41 rows=1 width=746174) (actual time=114.466..803.730 rows=23 loops=1)
        Index Cond: (b.geom && geom)
        Filter: _st_intersects(b.geom, geom)
        Rows Removed by Filter: 40
Planning time: 0.235 ms
Execution time: 4629.272 ms

समोच्च तालिका में केवल 82 पंक्तियाँ हैं, लेकिन लगभग 80000 तक कई कोने हैं। क्या ST_Intersection को तेज़ बनाने का कोई तरीका है?

जवाब

1 dr_jts Sep 25 2020 at 11:59

क्या आप समोच्च रेखाओं को छोटी रेखाओं में विभाजित कर सकते हैं, समान विशेषता जानकारी ले सकते हैं? तब स्थानिक सूचकांक अधिक प्रभावी होगा।

यह ST_Subdivideबहुभुज के लिए उपयोग के रूप में एक ही विचार है । यह अच्छा हो सकता है अगर लाइनों के लिए एक अनुरूप कार्य था, लेकिन ऐसा करने के लिए एसक्यूएल लिखना काफी आसान है।