clusterbuster icon indicating copy to clipboard operation
clusterbuster copied to clipboard

Update documentation to include instructions for spatial indexing of points in srid 3857

Open chriszrc opened this issue 4 years ago • 1 comments

Given that all the point intersection queries are executed with srid of 3857:

https://github.com/chargetrip/clusterbuster/blob/a47d2469e208a730b8e06dd4d189cce3a1b9059a/lib/queries/base.ts#L16-L24

A standard spatial index on the point geometry column won't be used (unless maybe the points are stored in 3857, but most I suspect are probably 4326). However regardless of srid on the geometry column, we can always add an expression (functional) index:

CREATE INDEX mytable_geom_3857_idx on mytable USING gist (ST_Transform(geom, 3857));

Which will of course speed up ST_INTERSECTS queries for all the tile requests.

PS - Was https://github.com/datalanche/node-pg-format or similar considered to more safely create parameterized queries?

chriszrc avatar Apr 13 '22 12:04 chriszrc

Hello @chriszrc . Do you want to create a PR for this issue. We are more than happy to review it and merge it.

cosmin-petrescu avatar Apr 15 '22 11:04 cosmin-petrescu