I'm using a big table imported by a *.shp file of the city of San Diego. When I run pgr_dijkstra it takes more or less 5000ms, even for small distances. I was thinking, in order to improve performance, how could I select a subset of the table San Diego? And more important, do you think it would improve the performance?

My idea is to, given a starting and ending point, select only an area (a circle, square,...) that contains both starting and ending point (plus an arbitrary margin). Is it possible?

1 Answer 1


Yes, this is common practice to speedup queries. As less data you load as faster will be the response. Bounding box selects are the fastest way to select a subset of the table. Don't forget to have an index on the geometry column though.

The following answer may give you an idea how to write your query: Why is any pgr_* routing function taking forever based on OSM data in an pgrouting enabled DB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.