Skip to content

docs: Document GiST and SP-GiST geography indexes#661

Open
charlesarchibong wants to merge 2 commits into
serverpod:mainfrom
charlesarchibong:docs/postgis-spatial-indexes
Open

docs: Document GiST and SP-GiST geography indexes#661
charlesarchibong wants to merge 2 commits into
serverpod:mainfrom
charlesarchibong:docs/postgis-spatial-indexes

Conversation

@charlesarchibong

@charlesarchibong charlesarchibong commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Documents the new PostGIS geography support, mainly the GiST and SP-GiST spatial index work from serverpod/serverpod#5392, and fixes a couple of things in the existing geography docs while I was in there.

What's in here:

  • The Geography indexes section in the indexing page now covers the gist and spgist types, gist as the default when no type is given, the type restriction and the no-mixing rule, with the exact code-generation error strings quoted. Added an spgist example and a note that SP-GiST needs a recent PostGIS.
  • Fixed the spatial filter operator name in the filter docs. It said dwithin, but the real API is distanceWithin. Checked against the serverpod source.
  • Added the SRID detail to the geography fields page (fixed to 4326, exposed as Geography.defaultSrid, no per-column SRID yet) plus a SQLite limitation note (stored as EWKT text, spatial ops throw at query time).

Document the gist/spgist index types for geography fields, the gist default, and the type/mixing restrictions, mirroring the spatial index support added in serverpod#5392.

Also correct the spatial filter operator name (dwithin -> distanceWithin) to match the API, and note the fixed SRID (Geography.defaultSrid) and SQLite limitations on geography fields.
Include the verbatim code-generation error strings for invalid geography index types and for mixing geography with non-geography fields, so the behaviour matches what serverpod#5392 emits.
A spatial index accelerates all spatial operations (`intersects`, `distanceWithin`, `distance`, `contains`, `within`). For tables with many rows and frequent spatial queries, adding one is strongly recommended.
:::

Geography fields only support the `gist` and `spgist` index types. Specifying any other type fails code generation with `The "type" property must be one of: gist, spgist.` An index may cover several geography columns, but geography and non-geography fields cannot be mixed in the same index — doing so fails with `Mixing geography and non-geography fields in the same index is not allowed.`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch on the dwithindistanceWithin fix, and the error strings match the source. One small thing: we keep em dashes out of the docs. Splitting this into two sentences fixes it (and reads a touch cleaner):

Suggested change
Geography fields only support the `gist` and `spgist` index types. Specifying any other type fails code generation with `The "type" property must be one of: gist, spgist.` An index may cover several geography columns, but geography and non-geography fields cannot be mixed in the same index — doing so fails with `Mixing geography and non-geography fields in the same index is not allowed.`
Geography fields only support the `gist` and `spgist` index types. Specifying any other type fails code generation with `The "type" property must be one of: gist, spgist.` An index may cover several geography columns, but it cannot mix geography and non-geography fields. Doing so fails with `Mixing geography and non-geography fields in the same index is not allowed.`

@developerjamiu developerjamiu added the documentation Improvements or additions to documentation label Jun 29, 2026

@developerjamiu developerjamiu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good changes. Just the tiny comments and we are good 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants