PostGIS implementation on self-hosted PostgreSQL

Adding PostGIS to a self-hosted PostgreSQL cluster touches installation, spatial indexing, licensing and every future major upgrade. This page sets out the decisions, the build sequence and what to hand to a partner or keep in-house.

On this page

When a PostGIS implementation on self-hosted PostgreSQL is worth planning

Plan a PostGIS implementation when location is a core part of your data and the database holding it must stay in infrastructure you control. If your teams need to store coordinates, run distance or containment queries, or join records by where they sit, PostGIS adds those capabilities inside PostgreSQL as an extension. It provides spatial data types, spatial functions and spatial indexes, so location queries run next to the relational data they relate to. Teams that usually implement it include utility and asset mapping groups, logistics and fleet operators, public sector agencies managing parcels or permits, healthcare organizations tracking facility locations, and field service teams. In each case the spatial data often carries personal or operationally sensitive information, which is why the database has to stay under your own control.

The extension cannot be treated as a separate project. PostGIS is installed into individual databases and is built against a specific PostgreSQL major version, so each database upgrade needs a compatible PostGIS build and a tested upgrade order. Backups and point-in-time recovery must capture the extension objects and spatial data together, and any standby servers must carry the same extension. PostgreSQL's versioning policy lists versions 14 through 18 as supported, with version 14 ending November 12, 2026 and version 18 supported until November 14, 2030. Confirm with the PostGIS project which PostGIS release supports each PostgreSQL major you plan to run, and build that pairing into your upgrade calendar from the start.

Before committing, answer three questions. First, does the workload need spatial functions and indexes, or would simple coordinate columns meet the requirement? Second, has counsel reviewed PostGIS's own license terms alongside the PostgreSQL License, which is a liberal license similar to BSD and MIT? Third, who owns the extension version, its upgrade and its restore testing? Record the PostgreSQL major version, the PostGIS version and the databases where the extension is installed. That inventory is the starting point for the rest of this page.

What PostGIS adds to PostgreSQL

PostGIS turns PostgreSQL into a spatial database, so geometry and geography become ordinary columns that SQL, indexes and backups already handle. The cards below cover the parts a self-hosting team has to design, size and keep working together, from data types to coordinate systems.

Spatial data types

PostGIS adds geometry and geography column types that store points, lines, polygons and collections. The geometry type works in a flat plane with the units of its coordinate system, while geography computes distances on the spheroid. Decide per dataset which type fits, because the two behave differently in distance and area functions. Confirm the exact type list and any version-specific additions in the PostGIS documentation for the version you plan to install.

PostgreSQL docs

Spatial indexing

PostGIS uses GiST-based spatial indexes to speed up bounding-box and spatial relationship queries. Without an index, most spatial filters scan the whole table, which slows as data grows. Build the index after large loads where practical, and check with EXPLAIN that the planner uses it for your real query patterns. Confirm index types and operator classes against the PostGIS version you deploy.

Spatial functions and operators

PostGIS provides functions for measurement, relationships such as containment and intersection, geometry construction and format conversion. These run inside SQL, so they can be tested with the same tools as the rest of the schema. Keep a list of the functions your applications call, because a PostGIS upgrade can change function behavior or signatures. Confirm the full function set against the reference for your chosen version.

Coordinate reference systems

PostGIS stores a spatial reference identifier with each geometry and uses a built-in table of coordinate systems that the PostgreSQL extension ships. Mixing SRIDs in one column or query produces wrong results without an error, so standardize on one system per dataset and transform explicitly at the boundary. Ask your GIS team which coordinate systems the source data uses, and confirm the reference data version your install carries.

Geometry validity and loading

Imported shapefiles, GeoJSON and utility records often contain invalid geometries, such as self-intersecting polygons, that break overlay and index functions. PostGIS provides validity checks and repair functions, but applying repairs silently changes source data. Plan a validation step in the load pipeline and record which rows were altered. Confirm the validity functions available in your PostGIS version before writing the load scripts.

Configuration decisions before installation

This table compares the configuration choices that shape a PostGIS build on self-hosted PostgreSQL, with the conditions under which each option fits and what it commits the team to. Read each row as a decision to settle with the data owners and the application team before anything is installed, since several of these choices are hard to reverse once data is loaded.

DecisionOptionWhen it fitsWhat it commits the team to
PostGIS version pairingPick the PostGIS release that supports the chosen PostgreSQL majorAny deployment, checked against the PostgreSQL major in use or plannedConfirm the pairing in the PostGIS release notes before install, and repeat the check at every PostgreSQL major upgrade
Extension enablement scopeEnable per databaseOnly one or a few databases need spatial dataEach new database needs an explicit CREATE EXTENSION step, which the provisioning process must include
Extension enablement scopeEnable in template databaseMany databases will be created and all should start with spatial supportEvery new database inherits the extension, so the team must accept the added objects in all of them
Coordinate reference systemStandardize on one SRID for stored dataData comes from one region or one survey standardTransforming later is possible but costly across large tables, so agree the SRID with data owners first
Coordinate reference systemStore mixed SRIDs with transforms at query timeData arrives from several sources with different reference systemsQuery logic must handle transforms, and indexes may need to match the transformed expression
Geometry versus geographyGeometry type with a planar SRIDLocal or projected analysis where distance math on a flat plane is acceptableDistances and areas are only accurate within the chosen projection, so document the projection for each dataset
Geometry versus geographyGeography type for global distance on the sphereData spans wide areas and distances must be measured on the earth's surfaceCalculations are heavier than geometry, so test query performance on representative data volumes
Raster supportLeave raster out of the installOnly vector data such as points, lines and polygons is neededSmaller footprint, but adding raster later is an extra install and migration step
Raster supportInclude raster supportImagery, elevation or gridded data must live in the databaseLarger storage and backup footprint, and raster data needs its own indexing and processing plan

How a PostGIS rollout runs, step by step

The sequence moves PostGIS from a version decision to a documented, restore-tested extension that survives a PostgreSQL major upgrade. Each step closes with a handover artifact so the client team knows what it receives.

  1. Confirm the PostgreSQL version and support window

    DeployOpen and the client's database owner confirm which PostgreSQL major version will host the data and check its end-of-support date against the versioning policy. Supported majors currently include 14 through 18, and 13 and earlier are unsupported, so an older cluster should be scheduled for upgrade before PostGIS is added. The output is a short decision record naming the PostgreSQL major, its end-of-life date, and the owner of the upgrade plan.

  2. Install and pin the matching PostGIS package

    The platform team installs the PostGIS package built for the chosen PostgreSQL major, from the operating system repository or the PostgreSQL project's packages, on every node that may run the database. The version is pinned so that operating system updates do not change it silently. Confirm the exact package name and version with the packaging source for your distribution. The output is an inventory of installed versions on each node, matched to the PostgreSQL build.

  3. Enable the extension in a staging database

    The DBA creates the extension in a staging database with CREATE EXTENSION postgis, then checks the installed version with SELECT PostGIS_Full_Version(). The team also confirms that the extension's objects land in the expected schema and that application roles can read the spatial types and functions they need. The output is a staging build log and a privilege matrix for the spatial schema.

  4. Load and validate sample spatial data

    Load a representative sample of geometries and geographies, including the coordinate reference systems the business uses, and run the queries the application will issue. Check that SRIDs are set consistently, that invalid geometries are identified and handled, and that spatial joins return expected results against a known reference set. The output is a validation report listing test queries, expected and actual results, and any data-quality rules the application must enforce.

  5. Add spatial indexes and measure query plans

    Create GiST spatial indexes on geometry and geography columns, then run EXPLAIN ANALYZE on the target queries and confirm the planner uses them. Run ANALYZE after bulk loads so the planner has current statistics. The team records index size and build time so the production sizing and maintenance window can be planned. The output is an index definition script and a query plan baseline for the critical spatial queries.

  6. Test backup and point-in-time restore with the extension

    Take a base backup, archive WAL, then restore to a point in time into a separate environment. After the restore, confirm that the PostGIS version matches, that the spatial functions run, and that the spatial indexes are intact and used by the planner. A restore that works for tables but leaves the extension unusable does not count as a pass. The output is a signed restore test record with the target time, restored version, and the query results compared against the source.

  7. Document the PostgreSQL and PostGIS upgrade procedure

    Write the upgrade runbook before go-live. It should cover how PostGIS is reinstalled or upgraded for the new PostgreSQL major, when ALTER EXTENSION postgis UPDATE is run, how the team re-tests spatial queries after a major upgrade, and the rollback path if the extension version does not match. Confirm the approach against the PostGIS release notes and the PostgreSQL upgrade documentation for the target version. The output is an approved runbook with a test checklist that the operations team can execute without the original builders.

How spatial indexing changes query design and load

Spatial indexing decides whether PostGIS queries stay fast as tables grow, and it changes how the application should ask questions of the database. Geometry columns are normally indexed with a GiST index, which PostgreSQL uses to narrow candidate rows by bounding box before PostGIS runs exact geometric tests. A query that calls a spatial function directly on an unindexed column scans the table, so the first design decision is to write filters in a form the planner can match to the index, such as an index-aware operator in the WHERE clause, and to confirm with EXPLAIN ANALYZE that the plan uses the index on realistic predicates.

Geometry type and filter pattern both shape the work. Points, lines and polygons with many vertices differ widely in index entry size and in the cost of each exact test, so very complex polygons may benefit from simplification or a separate table of coarser geometries for display. Nearest-neighbor ordering, containment checks and intersection joins each exercise the index differently, and a join between two large spatial tables can behave very differently from a single-point lookup. Write cost also rises with each index on a table that receives frequent inserts or geometry updates, because GiST entries must be maintained on every change, and bulk loads are often faster when the index is created after the data is loaded.

Sizing figures must come from your own benchmarks. Build a test copy of the database with representative row counts, geometry complexity and spatial distribution, then measure index build time, index size, write latency during load and the query plans for your top ten spatial queries. Repeat the test after any change to the geometry type, SRID or PostGIS version, and ask your implementation partner to include this benchmark in the scope and written acceptance criteria rather than relying on general guidance.

How PostGIS sits inside the PostgreSQL cluster

The diagram starts at the application clients, which send spatial queries to the primary PostgreSQL server. Inside that server, the PostGIS extension is enabled per database, so each database that holds geometry or geography columns carries its own copy of the extension objects. Changes flow from the primary to standbys and to the backup archive, and both paths must also carry the extension, since a replica or restored database without PostGIS cannot run the same queries. The upgrade path is a separate branch: it begins with planning for a PostgreSQL major version change and ends with confirming that the PostGIS version in use is supported on the new server before cutover.

Clients, primary server, standbys, backups and the separate upgrade branch for PostGIS.

What drives PostGIS implementation effort and cost

This table lists the main drivers of effort and cost for a PostGIS rollout on self-hosted PostgreSQL, with how to reduce each one and whether its cost is one-time or recurring. Use it to scope a quote, since the largest swings usually come from data quality and the number of datasets rather than from installing the extension.

DriverWhy it changes effort or costHow to keep it downOne-time or recurring
Number and scope of spatial datasetsEach layer adds schema design, loading, validation and testing work, and multiplies with every coordinate system involved.Start with the datasets the first applications need. Defer the rest to a later phase with its own written scope.One-time build, with recurring load work if datasets refresh
Coordinate reference systems (SRIDs)Mixed or undocumented projections force transformation logic into queries and cause silent distance and area errors.Pick one storage SRID per dataset class early, record it in a data standard, and reject uploads that do not match.One-time decision, with recurring checks at each load
Source data cleanupInvalid geometries, duplicate features, unclosed rings and inconsistent attributes often take more time than the database work itself.Ask the data owner for sample extracts before quoting. Agree which validation rules are enforced at import and who fixes rejected records.One-time for the initial load, recurring for each refresh
Spatial index designGiST indexes, expression indexes and the choice of geography or geometry type change build time, storage and query speed.Test index choices on representative data volumes and query shapes. Keep the index plan in the same document as the schema.One-time design, with recurring index maintenance as data grows
Application query changesExisting code using text coordinates or application-side distance math must be rewritten to use spatial functions and indexes.Inventory the queries that will touch spatial data and migrate the highest-volume ones first. Confirm which application teams own each change.One-time, with recurring review as features are added
Replication and backup testingStandbys and point-in-time recovery must restore spatial tables and the extension correctly, which requires dedicated test runs.Include a PostGIS-enabled restore in the recovery test plan and record the result. Confirm which replicas serve spatial reads.One-time setup, with recurring restore tests
Major PostgreSQL and PostGIS upgrade planningEach PostgreSQL major upgrade needs a PostGIS version that supports it, plus extension updates tested against the same queries.Check the PostGIS release notes for the target PostgreSQL version before the upgrade plan is written. Keep a staging copy for rehearsal.Recurring, tied to each upgrade cycle
GPL licensing reviewDistribution of modified code or bundled components may trigger obligations that the legal team needs to review.Confirm with counsel early whether any distribution is planned. Internal use alone usually avoids redistribution questions.One-time review, with recurring review on version changes

How PostGIS connects to the rest of the platform

PostGIS runs inside a PostgreSQL cluster, so its data, performance and access follow the same rules as everything else in that cluster. The cards below cover the connections to check before go-live, since a decision in one area often changes the work in another.

Replication and backups

PostGIS objects, spatial indexes and extension catalog entries replicate and back up with the rest of the cluster, so a standby or a point-in-time recovery restores geometry data only if the extension is installed on the target. Check that the restore runbook includes a test query against a geometry column and a spatial index. Confirm that every standby runs the same PostGIS version as the primary before a failover is tested. Restore tests should include spatial queries, not just row counts.

Continuous archiving docs

pgRouting for network analysis

Teams that add routing, such as shortest path or driving distance, build it on top of PostGIS geometry and graph tables. The road or utility network data must be refreshed on a schedule, and the graph rebuild affects storage and maintenance windows. Ask who owns the source data, how often it changes and how large the graph will grow before you size the cluster. Treat routing as a separate design decision with its own data pipeline.

Shared cluster with other extensions

Vector search with pgvector, audit logging with pgAudit and time-series tooling can all share one cluster with PostGIS. Each extension adds its own shared library, catalog objects and upgrade path, and each must match the installed PostgreSQL major version. Build a compatibility matrix before a major upgrade and test the full set of extensions together. Shared clusters also share memory, I/O and maintenance windows, so one heavy spatial workload can affect the others.

Query performance monitoring

Spatial queries often look fine in small tests and slow down when table size or geometry complexity grows. Monitor slow statements, index usage and table bloat on spatial tables, and track how long index builds and vacuum runs take. Ask your monitoring vendor or team whether query-level statistics can be grouped by schema or table so that GIS workloads are visible on their own dashboards. Review EXPLAIN output for spatial queries after each data load.

GIS clients through PgBouncer

Desktop GIS tools, map servers and web applications often open many short connections, and a connection pooler such as PgBouncer can reduce the load on the database. Confirm that each client's session settings, prepared statements and transaction behavior work in the chosen pooling mode before you route them through the pooler. Pooled connections also change how you attribute activity in logs, so plan for the user and application name that reaches the database.

PgBouncer site

Access control through PostgreSQL roles

Access to spatial tables should follow the same role model as the rest of the database. Grant read access to published layers, separate write roles for editors and loaders, and restrict who can create or alter extensions. Check the authentication method used by GIS clients, since older password methods are deprecated in favor of SCRAM. Review grants on the schemas that hold geometry data during every access review.

Authentication methods docs

Keeping PostGIS in step during PostgreSQL major upgrades

A major PostgreSQL upgrade is not complete until PostGIS runs on the new major version. The PostGIS extension is compiled against a specific PostgreSQL major, and the target server needs a PostGIS build that supports that major before any data moves. Put this check first in the upgrade plan, before choosing between pg_upgrade and logical replication. Confirm the PostGIS release you intend to run supports the target PostgreSQL version using the project's own compatibility documentation, and record the exact PostGIS and GEOS, PROJ and GDAL library versions you will install on the new servers. Do not assume that the version you run today will carry over, and do not treat a successful package install as proof that the extension will load.

The upgrade method changes how much PostGIS work you carry. With pg_upgrade, the extension objects are migrated with the catalog, but the new binaries and PostGIS shared libraries must be installed before the upgrade runs, and you should run ALTER EXTENSION postgis UPDATE and check spatial function behavior afterward. With logical replication, PostGIS must be installed and matched on the subscriber, and the geometry and geography columns, spatial indexes and any extension-owned types must exist there before the initial table copy. The PostgreSQL upgrade documentation states that logical replication works between different major versions and allows a cutover with only several seconds of downtime. That short window only holds if the subscriber's PostGIS setup was tested in advance, so rehearse the full cutover, including SELECT PostGIS_full_version(); on both sides, against a copy of production data.

Plan a rollback path that keeps the old cluster intact until spatial queries, GiST index usage and application map or routing features pass your checks. Ask your team to confirm whether PostGIS upgrades in your environment will be scheduled separately from the PostgreSQL minor updates that arrive at least every three months, because each change to either component can require the other to be checked. Record the PostgreSQL version, PostGIS version and library versions in your change ticket so an auditor or on-call engineer can see what was running before and after the upgrade.

Questions teams ask before hiring help with PostGIS

What drives the cost of adding PostGIS to self-hosted PostgreSQL?

Cost follows the written scope, not a fixed package. The main drivers are how many PostgreSQL clusters need the extension, how much geospatial data must be loaded and cleaned, how many coordinate systems and sources are involved, whether existing applications need query changes, how much indexing and performance testing is required, and whether backup, monitoring and high availability changes are included. A fixed-scope engagement is priced from that written scope, so the one-time build is separate from any recurring retainer for upgrades or support. Ask the quote to itemize each of these items, state who does the work, and list which tasks stay with your own staff.

How long does a PostGIS implementation take to complete?

No duration applies to every environment, so the timeline is set by the scope. The biggest factors are the volume and messiness of the spatial data, the number of layers and applications that query it, whether existing GIS data must be migrated, how many non-production environments must be built and tested, and how long your change approval process takes. Deadlines can also come from the platform itself. Under the PostgreSQL versioning policy, PostgreSQL 14 is supported until November 12, 2026, so a cluster on that version may need an upgrade plan alongside the PostGIS work. Ask for milestones with dependencies in the written scope.

What must our team provide before a PostGIS project starts?

The project depends on three inputs from your side. First, sample and production-representative datasets, with named data owners who can explain coordinate systems, update frequency and quality issues. Second, staff time from the database administrators, application owners and, where relevant, the GIS team, for design reviews and acceptance tests. Third, environments: a non-production PostgreSQL cluster that matches the production major version, sizing, and extension packaging, plus access to your backup, monitoring and change management tools. Confirm who approves production changes and how long that approval takes, because it often sets the calendar more than the technical work does.

Can an in-house DBA team install and run PostGIS without outside help?

Often yes, if the team already runs PostgreSQL in production and has tested its operations. Installing the extension is the smaller task. The harder parts are choosing spatial index types and tuning queries against realistic data, keeping the extension version matched to the PostgreSQL major version on every primary and standby, and making sure backups and point-in-time recovery restore spatial data correctly. Your team should also be comfortable with high availability and recovery testing, because PostgreSQL does not detect primary failure on its own. A useful self-assessment is whether your team has already done a major upgrade and a restore test on a PostgreSQL cluster without outside help.

How does a licensing review fit into a PostGIS project?

Licensing review should happen before the design is frozen, because it can affect how the database is distributed and how it is embedded in products. PostgreSQL is released under the PostgreSQL License, a permissive license similar to the BSD and MIT licenses. PostGIS is covered by the GPL, as the topic notes, and GPL obligations depend on how the software is distributed, modified and combined with other code, including whether you ship it to customers. Treat the license determination as a legal decision for your counsel. Give them a written description of how PostGIS will be deployed, used and distributed, and ask the implementation quote to state which components and versions will be installed.

How is PostGIS handled during a PostgreSQL major upgrade?

The extension must be installed for the new PostgreSQL major version before cutover, and its version must be confirmed against the target release. PostgreSQL documents three upgrade routes: a dump and restore, pg_upgrade, and logical replication. Logical replication works between major versions and can keep downtime to several seconds, which makes it a common choice for spatial workloads that cannot stop for long. PostgreSQL 18 pg_upgrade retains planner statistics across major upgrades, which helps query performance after cutover. Test the spatial queries and indexes on the new version, rebuild anything the upgrade route does not carry over, and include the PostGIS step in the rollback plan. Ask the quote to name the route and the test evidence.

What should a written PostGIS quote include?

A useful quote names the PostgreSQL and PostGIS versions, the environments in scope, the datasets and their expected volume, and the applications that query the data. It should list each deliverable, including extension installation, spatial index design, query testing, backup and restore verification, and documentation. It should also state the upgrade approach, the licensing information supplied to your counsel, and the assumptions about your staff time and approvals. Separate one-time build work from any recurring upgrade or support retainer, and confirm what happens if the data turns out to be larger or less clean than the sample. Ask for acceptance criteria so both sides know when the work is complete.

How DeployOpen scopes and delivers PostGIS implementations

DeployOpen plans, installs, tests and hands over PostGIS on PostgreSQL servers and containers that your organization controls. Each engagement starts with a written scope that names the databases, spatial data, extension versions and upgrade path before any build work begins.

How we scope

  • Inventory the PostgreSQL major versions, hosts and databases that will carry spatial data
  • Confirm the PostGIS version that matches your target PostgreSQL major before installation
  • Record the spatial data types, coordinate reference systems and expected table sizes
  • Agree in writing how spatial indexes, backups and upgrade testing are covered
  • Engagements are fixed-scope, with deliverables and timelines set out before work starts

How we build

  • Install PostGIS through your approved packages or images and enable it per database
  • Load representative spatial datasets and review GiST index use with EXPLAIN plans
  • Document extension ownership, roles and privileges so schema changes stay controlled
  • Confirm that backups and point-in-time recovery capture PostGIS objects and settings
  • Test a PostGIS-enabled restore in a separate environment before go-live

How we hand over

  • Deliver the written configuration, versioning record and runbook for your team
  • Document the PostGIS and PostgreSQL version pairing and the steps to re-check it at upgrade
  • Provide a PostgreSQL major upgrade rehearsal plan that includes spatial functions and indexes
  • Walk your database, GIS and platform staff through operations and recovery procedures
  • Hand over test scripts that confirm geometry queries return expected results after changes

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers
  • Plan PostGIS upgrades alongside each planned PostgreSQL minor and major release
  • Retest spatial queries, indexes and restores after every extension or database upgrade
  • Review GPL licensing obligations with your legal team when distributing any modified code
  • Keep the runbook current as your spatial workloads and data volumes change

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.