I import map from file russia.osm.pbf using osm2po.
Why the low speed function call pgr_dijkstra in database Postgresql (>2 minute)?
My steps:
java -Xmx6g -jar osm2po-core-5.0.0-signed.jar prefix=pgr tileSize=45x45,1,c RU.osm.pbf
set PSQL="c:\Program Files\PostgreSQL\9.4\bin\psql.exe"
set PGPORT=5432
set PGHOST=localhost
set PGPASSWORD=1
cd pgr
%PSQL% -U postgres -d pgrouter -q -f "pgr_2po_4pgr.sql"
The database created a table with an index on the field source and target:
CREATE TABLE pgr_2po_4pgr
(
id integer NOT NULL,
osm_id bigint,
osm_name character varying,
osm_meta character varying,
osm_source_id bigint,
osm_target_id bigint,
clazz integer,
flags integer,
source integer,
target integer,
km double precision,
kmh integer,
cost double precision,
reverse_cost double precision,
x1 double precision,
y1 double precision,
x2 double precision,
y2 double precision,
geom_way geometry(LineString,4326),
CONSTRAINT pkey_pgr_2po_4pgr PRIMARY KEY (id)
)
My query:
SELECT * FROM pgr_dijkstra(
'SELECT id, source, target, cost FROM pgr_2po_4pgr',
30837, 682499,false, false
)
Query execution time is more than 2 minutes. Why?
This query is very fast (~1 second):
http://localhost:8888/Osm2poService?cmd=fr&source=30837&target=682499&findShortestPath=true&ignoreRestrictions=false&ignoreOneWays=false&routerClassId=0&heuristicFactor=0.0&maxCost=0.0&format=geojson