postgres-impl-postgis-geometry-2d
Installation
SKILL.md
postgres-impl-postgis-geometry-2d
Quick Reference :
PostGIS adds two spatial column types to PostgreSQL. geometry uses planar
(flat) math in the units of its coordinate system : fast, supports every
PostGIS function, but distances are meaningful only in a projected SRID.
geography uses spheroidal math on the WGS84 ellipsoid : slower, smaller
function set, but distances are always in meters and correct globally.
Three rules drive every spatial query :
- ALWAYS create a
GISTindex on the spatial column. Without it, every spatial predicate falls back to a sequential scan. - ALWAYS use
ST_DWithin(a, b, dist)for proximity filters, NEVERST_Distance(a, b) < dist. OnlyST_DWithinkeeps the GiST index. - ALWAYS keep both operands in the same SRID. Mixed SRIDs raise an error or
silently produce wrong answers. Reproject with
ST_Transform.