SYSTEM Cited by 1 source
pg_tileserv¶
What it is¶
pg_tileserv is a lightweight HTTP vector-tile server
for PostGIS, developed by Crunchy Data
(github.com/CrunchyData/pg_tileserv).
It exposes a simple URL contract —
/{schema}.{object}/{z}/{x}/{y}.pbf — where {object}
can be either a table with a geometry column or a PL/SQL
function with the signature
(z integer, x integer, y integer [, ...]) RETURNS bytea.
pg_tileserv is the canonical thin-HTTP-shim instance of the database-as-tile-server pattern: the tile pipeline (grid-of-tiles generation, zoom-dependent geometry generalisation, MVT encoding) lives in PostGIS functions; pg_tileserv is only an HTTP frontend over the database connection — no tile rendering, no caching, no geometry processing of its own.
Configuration and deployment shape¶
- Configuration: TOML file (example in
config/pg_tileserv.toml.example).
BasePathoverrides the URL prefix;Debug = trueenables logging. Loaded via-cflag orCONFIG_FILEenv var. - Database connection:
DATABASE_URLenv var (libpq connection string).PGPASSWORDfor auth when not embedded in the URL. - Attribute columns pass-through: pg_tileserv packs all non-geometry columns from a spatial table into the MVT alongside the geometry, so the browser can restyle layers without another database round-trip.
- Function layers: user-defined PL/SQL functions
become
/schema.function/{z}/{x}/{y}.pbfendpoints. Extra function parameters (beyond z/x/y) appear as query-string arguments.
Seen in¶
- sources/2021-12-01-zalando-maps-with-postgresql-and-postgis
— Zalando's production instance: pg_tileserv deployed
as a Kubernetes
Deployment(replicas: 1) using thepramsey/pg_tileserv:latestDocker image, behind Zalando's oauth2-proxy at/tileserver/, reading the database via the Service the Postgres Operator creates (acid-geo:5432) with the reader role from the operator-managed Secret (map_db_reader_user.acid-geo.credentials). Configuration mounted viaConfigMapat/config. Tile URL shape as actually served:${BASE_URL}/tileserver/geo.boundaries_europe/{z}/{x}/{y}.pbf. Also runs a PL/SQL function layer (population_hexagons(z, x, y, step)) that returns a hexagon-grid population heatmap computed viaST_HexagonGrid+ LATERAL join to a Eurostat 1 km² grid +ST_AsMVT. First wiki canonical page.
Related¶
- systems/postgis — the tile-producing database extension.
- systems/postgresql — the host database.
- systems/leaflet — the typical browser consumer
(
VectorGridclass). - systems/zalando-postgres-operator — the operator that provisions the database and secrets pg_tileserv connects to in Zalando's stack.
- concepts/vector-tiles — the format pg_tileserv serves.
- patterns/database-as-tile-server-middleware-replacement — the pattern pg_tileserv canonicalises.