Inside the Engine of “KnoWaterleak”: Real-Time Search and On-Demand Vector Tiles for Large Pipeline Data
2026-09-03 , Ran2

From our production “KnoWaterLeak” leakage-risk service, we show real-time, on-demand vector tiles for large pipeline datasets. We cover in-database MVT generation, safe DSL-to-JSON translation, routing between tile and aggregation endpoints, and data-model choices that keep latency low and database load predictable.


This talk shares a production case study from “KnoWaterLeak,” a multi-tenant water pipeline leakage-risk assessment service. Tenants manage hundreds of thousands of pipe segments, and users expect smooth map navigation with on-the-fly filtering by asset attributes and risk overlays. Since tile content varies with both query conditions and permissions, pre-generating static tiles is not practical.

We present an architectural pattern we use in production to deliver dynamic vector tiles with low latency and predictable database load. The core idea is to treat the database as the rendering engine: we generate Mapbox Vector Tiles (MVT) inside PostGIS using tile bounds and ST_AsMVT. The application layer acts as a gateway that validates and translates request parameters into database-function inputs for the tile endpoint, and routes requests to separate non-tile endpoints when users need aggregated results (for example, total pipeline length). This keeps MVT encoding and heavy spatial computation in the database, while the application focuses on safe parameter handling and efficient streaming of responses.

A key challenge is enabling expressive, user-defined filters without exposing the system to SQL injection or unbounded query complexity. We introduce a small DSL for filter expressions, validate it with a strict whitelist, and convert it into a structured JSON parameter. With a tile-serving layer that can map HTTP query parameters to PostgreSQL function calls (Martin in our deployment), we avoid dynamic SQL in the application: the database-side tile function interprets the JSON and applies optimized query paths such as early returns, zoom-threshold checks, and EXISTS-based joins.

We also highlight data-model and preprocessing choices that are essential for performance at scale. Concrete examples include designing a single table that co-locates domain attributes, geometry, and zoom-level visibility thresholds; precomputing expensive metrics such as intersection lengths between pipe segments (LineString) and risk zones (Polygon) for aggregation and visualization; and building composite (and, where appropriate, partial) indexes tailored to common filter combinations to minimize joins and keep query plans predictable.

Grounded in lessons from this production deployment, we present a set of reusable patterns for PostGIS-driven vector tile delivery. The talk covers key trade-offs—precompute vs. on-demand computation, safe and maintainable dynamic filtering, and database function design for stable performance—so attendees can learn from the design decisions behind a real-world, PostGIS-driven tile pipeline.


Level of technical complexity: 2 - intermediate Indicate what is (are) the open source project(s) essential in your talk:

Essential open source projects: PostgreSQL, PostGIS, and Martin.
Also used in our implementation: Django and Redis (for request routing/streaming and permission caching).

I make my conference contribution available under the CC BY 4.0 license. The conference contribution comprises the abstract, the text contribution for the conference proceedings, the presentation materials as well as the video recording and live transmission of the presentation: