Start Here
Location data looks special, but many location questions are still normal product questions.
Which stores are nearby? Which driver is inside this zone? Which listing is within this city boundary? Those queries usually need product data and location data together.
PostGIS keeps that work in SQL.
What To Build First
For nearby search, start with a geography point and a GiST index.
create extension if not exists postgis;
create table places (
id bigserial primary key,
name text not null,
location geography(point, 4326) not null
);
create index places_location_gix
on places using gist (location);
Then query with a clear radius.
select id, name
from places
where st_dwithin(
location,
st_makepoint(-73.9857, 40.7484)::geography,
2000
)
order by st_distance(
location,
st_makepoint(-73.9857, 40.7484)::geography
);
The radius is in meters when you use geography.
Good First Uses
- Nearby search.
- Store locators.
- Delivery zones.
- Basic boundary checks.
- Product queries that combine location with accounts, users, or inventory.
This works well when location is one part of the product model, not a separate mapping platform.
The Part People Skip
Define “nearby” in product terms.
Sometimes nearby means shortest distance. Sometimes it means same service zone, currently available, within a polygon, or ranked by business rules. Those are different queries.
Also be clear about geometry vs geography. geography is a practical start for Earth-distance queries. geometry is often better for projected data, planar calculations, or advanced GIS work.
What This Does Not Replace
PostGIS does not replace a full map stack.
If you need tile serving, routing, complex spatial processing, or a dedicated GIS workflow, that may become separate infrastructure. PostGIS can still be the source of truth.
Move To A Geo Platform When
- You need tiles, routing, or map rendering pipelines.
- Spatial processing is the main workload.
- A GIS team owns the data lifecycle.
- Product queries no longer need to join location with normal app data.
- You need tools and workflows that are outside SQL.
Until then, PostGIS gives you a lot before you add another system.