Use _cdb_estimated_extent instead of ST_Extent
With a 3.8M points table, this was a ~30% gain in my local env.
This commit is contained in:
parent
5010109c7d
commit
564ab75d2d
@ -71,7 +71,7 @@ AS $$
|
|||||||
-- considered tiles.
|
-- considered tiles.
|
||||||
EXECUTE Format('
|
EXECUTE Format('
|
||||||
WITH RECURSIVE t(x, y, z, e) AS (
|
WITH RECURSIVE t(x, y, z, e) AS (
|
||||||
WITH ext AS (SELECT ST_Extent(the_geom_webmercator) g FROM %1$s),
|
WITH ext AS (SELECT _cdb_estimated_extent(%6$s) as g),
|
||||||
base AS (
|
base AS (
|
||||||
SELECT (-floor(log(2, (greatest(ST_XMax(ext.g)-ST_XMin(ext.g), ST_YMax(ext.g)-ST_YMin(ext.g))/(%4$s*%5$s))::numeric)))::integer z
|
SELECT (-floor(log(2, (greatest(ST_XMax(ext.g)-ST_XMin(ext.g), ST_YMax(ext.g)-ST_YMin(ext.g))/(%4$s*%5$s))::numeric)))::integer z
|
||||||
FROM ext
|
FROM ext
|
||||||
@ -101,7 +101,7 @@ AS $$
|
|||||||
WHERE t.e > %2$s AND t.z < (base.z + %3$s)
|
WHERE t.e > %2$s AND t.z < (base.z + %3$s)
|
||||||
)
|
)
|
||||||
SELECT MAX(e/ST_Area(CDB_XYZ_Extent(x,y,z))) FROM t where e > 0;
|
SELECT MAX(e/ST_Area(CDB_XYZ_Extent(x,y,z))) FROM t where e > 0;
|
||||||
', reloid::text, min_features, nz, n, c)
|
', reloid::text, min_features, nz, n, c, reloid::oid)
|
||||||
INTO fd;
|
INTO fd;
|
||||||
RETURN fd;
|
RETURN fd;
|
||||||
END
|
END
|
||||||
|
Loading…
Reference in New Issue
Block a user