2

我有一个包含大约 800k 点的表,其中包含存储在 PostGIS 上并使用 ST_AsMVTGeom 提供的水深测量的信息,它连接到使用 Leaflet 开发的 Web 应用程序,但是在某个级别(0-5)一个单一的矢量瓦片包含所有数据使查询非常慢(需要几分钟)。我想知道是否存在(whitin PostGIS)一种根据缩放级别简化行输出的方法。

我正在使用以下查询来创建图块:

SELECT ST_AsMVT(q.*, 'bathymetry_layer', 4096, 'geom')
    FROM (
      SELECT
          c.gid AS id,
          c.x,
          c.y,
          c.z,
          c.name,
          c.inst,
          ST_AsMVTGeom(
              geom,
              ST_MakeEnvelope(-86.8798828125, 20.632784250388028, -86.8359375, 20.673905264672843, 4326),
              4096,
              256,
              false
          ) geom
      FROM bathymetry_table WHERE geom && ST_MakeEnvelope(-86.8798828125, 20.632784250388028, -86.8359375, 20.673905264672843, 4326) AND ST_Intersects(geom, ST_MakeEnvelope(-86.8798828125, 20.632784250388028, -86.8359375, 20.673905264672843, 4326))
    ) q

解释分析的结果:

Index Scan using geodat_batimetria_catoche_xcalak_geom_idx on geodat_batimetria_catoche_xcalak c  (cost=0.29..8.56 rows=1 width=101) (actual time=0.117..11539.038 rows=434271 loops=1)
  Index Cond: ((geom && '0103000020E610000001000000050000002B8716D9CECB55C0516B9A779CA234402B8716D9CECB55C0D34D621058493540492EFF21FD9E55C0D34D621058493540492EFF21FD9E55C0516B9A779CA234402B8716D9CECB55C0516B9A779CA23440'::geometry) AND (geom && '0103000020E610000001000000050000002B8716D9CECB55C0516B9A779CA234402B8716D9CECB55C0D34D621058493540492EFF21FD9E55C0D34D621058493540492EFF21FD9E55C0516B9A779CA234402B8716D9CECB55C0516B9A779CA23440'::geometry))
  Filter: _st_intersects(geom, '0103000020E610000001000000050000002B8716D9CECB55C0516B9A779CA234402B8716D9CECB55C0D34D621058493540492EFF21FD9E55C0D34D621058493540492EFF21FD9E55C0516B9A779CA234402B8716D9CECB55C0516B9A779CA23440'::geometry)
  Rows Removed by Filter: 5
Planning time: 7.222 ms
Execution time: 11579.044 ms
4

0 回答 0