Pg_tileserv (developed by Crunchy Data and open-source contributors under the Apache-2.0 license) is a fast, lightweight vector tile server written in Go that serves Mapbox Vector Tiles (MVT) directly from PostgreSQL and PostGIS databases. Designed for web GIS developers, spatial database engineers, and mapping applications, pg_tileserv queries spatial tables, views, and custom PostGIS SQL functions on demand—exposing live vector tile endpoints and TileJSON metadata with minimal configuration and a single compact binary or container image.
1. In-Depth Review: Why PostGIS & Web GIS Developers Use pg_tileserv
- Live PostGIS Vector Tiles Without Pre-Tiling Pipelines: Generates MVT tiles dynamically from PostgreSQL/PostGIS using `ST_AsMVT` and `ST_AsMVTGeom`, so edits to land parcels, roads, or infrastructure appear on web maps immediately.
- Custom Parameterized SQL Functions as Map Layers: Turns PostGIS functions returning `bytea` MVT output into dynamic query-driven vector tile layers—ideal for real-time spatial filters, buffers, heatmaps, or custom joins.
- Small Footprint, Fast Go Performance & Easy Deployment: Runs as a single compiled Go binary or official Docker container with built-in web preview maps, TileJSON endpoints, and environment/TOML configuration.
2. Key Features & Capabilities
- Dynamic MVT Generation from PostGIS Tables & Views: Automatically discovers spatial tables and views with geometry columns and serves MVT tiles at `/<schema>.<table>/{z}/{x}/{y}.pbf`.
- Function-Based Vector Tile Layers: Publishes PostGIS SQL/PLpgSQL functions accepting zoom/tile or custom URL query parameters to return filtered vector tiles.
- Built-In TileJSON & HTML Map Previewer: Provides TileJSON metadata endpoints and lightweight built-in preview pages for inspecting layers quickly.
- TOML Config & Environment Variable Support: Configures database connections (`DATABASE_URL`), port/host bindings, cache/tile limits, and security settings cleanly.
- Cross-Platform Go Binary & Docker Container: Runs on Linux, macOS, and Windows or inside Docker/Kubernetes environments.
- Free & Open-Source (Apache-2.0 License): Free to self-host and use in personal, academic, government, and commercial projects.
- Official Links: Free Trial, Free / Education & Pricing
Always download pg_tileserv binaries, container images, and documentation directly from official portals:
- Official pg_tileserv GitHub Repository & Releases: https://github.com/CrunchyData/pg_tileserv
- Official pg_tileserv Documentation & Configuration Guide: https://access.crunchydata.com/documentation/pg_tileserv/
- Official PostGIS Vector Tile (`ST_AsMVT`) Documentation: https://postgis.net/docs/ST_AsMVT.html
- Official MapLibre GL JS Vector Tile Reference: https://maplibre.org/maplibre-gl-js/docs/
4. Step-by-Step Installation Guide
- Check PostgreSQL, PostGIS & Runtime Requirements: Confirm you have a running PostgreSQL database with the `postgis` extension enabled, valid geometry SRIDs, and a Linux, macOS, or Windows host (or Docker runtime).
- Download Release Binary or Pull Docker Image: Visit https://github.com/CrunchyData/pg_tileserv/releases to download a pre-built binary for your OS, or pull the official container image (`ghcr.io/crunchydata/pg_tileserv`).
- Set Database Connection & Optional Config: Set `DATABASE_URL` (for example `postgres://user:password@localhost:5432/gisdb`) or create a `pg_tileserv.toml` configuration file.
- Start `pg_tileserv` & Verify Endpoints: Launch `pg_tileserv` (default port `7800`) and open `http://localhost:7800/` in your browser to inspect discovered layers and preview maps.

5. How to Use pg_tileserv: Beginner Workflow
- Prepare Indexed Spatial Tables in PostGIS: Load your vector datasets into PostGIS with a defined `SRID` (such as `EPSG:4326` or `EPSG:3857`) and create a spatial `GIST` index on the geometry column.
- Launch pg_tileserv Connected to PostGIS: Run `DATABASE_URL=postgres://postgres:password@localhost:5432/gisdb pg_tileserv` to expose spatial tables and compatible functions automatically.
- Test Layers in the Built-In Preview & Check TileJSON: Open `http://localhost:7800/<schema>.<table>.json` to inspect TileJSON metadata, or view the layer in the built-in browser preview page.
- Connect to MapLibre GL JS, OpenLayers, or QGIS: Point your web mapping client or QGIS Vector Tile connection to the TileJSON URL (`http://localhost:7800/<schema>.<table>.json`).
- Add Custom SQL Tile Functions & Production Proxy: Create parameterized PostGIS functions for dynamic filtering and place Nginx/Caddy or caching in front for production traffic.
6. Frequently Asked Questions (FAQ)
- Is pg_tileserv completely free for commercial use?Yes. pg_tileserv is open-source software released under the Apache License 2.0 by Crunchy Data and contributors.
- What is the difference between pg_tileserv and Martin?Both serve dynamic PostGIS vector tiles directly from PostgreSQL; pg_tileserv is written in Go with a strong focus on PostGIS tables/views/functions and TOML config, while Martin is written in Rust and also serves PMTiles, MBTiles, sprites, and fonts in one binary.
- Does pg_tileserv require pre-generated `.mbtiles` or `.pmtiles` files?No. pg_tileserv queries PostGIS dynamically when tiles are requested, though spatial indexes (`GIST`) and proper zoom/simplification tuning remain essential for large datasets.