Skip to content

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). BasePath overrides the URL prefix; Debug = true enables logging. Loaded via -c flag or CONFIG_FILE env var.
  • Database connection: DATABASE_URL env var (libpq connection string). PGPASSWORD for 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}.pbf endpoints. 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 the pramsey/pg_tileserv:latest Docker 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 via ConfigMap at /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 via ST_HexagonGrid + LATERAL join to a Eurostat 1 km² grid + ST_AsMVT. First wiki canonical page.
Last updated · 501 distilled / 1,218 read