ST_Slope query is slow.

Dapeng Wang wangdapeng20191008 at gmail.com
Mon Apr 8 23:42:04 PDT 2024


Hello,

-The computation of slope (in degrees) is relatively slow, taking about 20
seconds for analysis using ArcGIS Pro.

version:pg12+postgis340

--postgis_full_version
POSTGIS="3.4.0 0" [EXTENSION] PGSQL="120" GEOS="3.12.0-CAPI-1.18.0"
SFCGAL="SFCGAL 1.4.1, CGAL 5.4.5, BOOST 1.72.0" PRO
J="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org
USER_WRITABLE_DIRECTORY=/home/postgres/.local/share/proj
DATABASE_PATH=/usr/local/proj-8.2.1/share/proj/proj.db" GDAL="GDAL 3.6.2,
released 2023/01/02" LIBXML="2.9.11" LIBJSON="
0.15" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" TOPOLOGY RASTER

raster2pgsql -I -s 4326 -t 32x32 "/opt/raster_data/changjiang12.tif" | psql
-h localhost -p5432 -Upostgres -dpostgis340
-After importing, the TIFF file is 14MB and 12198 rows.

postgis340=# \d changjiang12
                             Table "public.changjiang12"
 Column |  Type   | Collation | Nullable |                  Default
--------+---------+-----------+----------+-------------------------------------------
 rid    | integer |           | not null |
nextval('changjiang12_rid_seq'::regclass)
 rast   | raster  |           |          |
Indexes:
    "changjiang12_pkey" PRIMARY KEY, btree (rid)
    "changjiang12_st_convexhull_idx" gist (st_convexhull(rast))

postgis340=# EXPLAIN ANALYSE select ST_Slope(rast) as slope from
changjiang12;
                                                       QUERY PLAN
------------------------------------------------------------------------------------------------------------------------
 Seq Scan on changjiang12  (cost=0.00..4894.48 rows=12198 width=32) (actual
time=22.371..142759.655 rows=12198 loops=1)
 Planning Time: 0.836 ms
 Execution Time: 142764.987 ms
(3 rows)
Time: 142770.199 ms (02:22.770)

-Where can improvements be made?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20240409/c710debd/attachment.htm>


More information about the postgis-users mailing list