From 6a022f24dcb166fc9daee967739026c7d356e67d Mon Sep 17 00:00:00 2001 From: Jannis R Date: Wed, 14 Dec 2022 20:09:49 +0100 Subject: [PATCH] =?UTF-8?q?add=20{arrivals=5Fdepartures,connections}=20by?= =?UTF-8?q?=20stop=20benchmark,=20refresh=20others=20=E2=9A=A1=EF=B8=8F?= =?UTF-8?q?=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/arrs_deps_by_non_existent_stop.sql | 5 +++ benchmark/arrs_deps_by_stop.sql | 5 +++ .../connections_by_non_existent_stop.sql | 5 +++ benchmark/connections_by_stop.sql | 5 +++ benchmark/index.sql | 4 +++ benchmark/run.sh | 2 +- readme.md | 32 +++++++++++-------- 7 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 benchmark/arrs_deps_by_non_existent_stop.sql create mode 100644 benchmark/arrs_deps_by_stop.sql create mode 100644 benchmark/connections_by_non_existent_stop.sql create mode 100644 benchmark/connections_by_stop.sql diff --git a/benchmark/arrs_deps_by_non_existent_stop.sql b/benchmark/arrs_deps_by_non_existent_stop.sql new file mode 100644 index 0000000..fbccfee --- /dev/null +++ b/benchmark/arrs_deps_by_non_existent_stop.sql @@ -0,0 +1,5 @@ +SELECT * from bench( +'SELECT count(*) +FROM arrivals_departures +WHERE stop_id = ''definitely-non-existent''' +); diff --git a/benchmark/arrs_deps_by_stop.sql b/benchmark/arrs_deps_by_stop.sql new file mode 100644 index 0000000..a641eb5 --- /dev/null +++ b/benchmark/arrs_deps_by_stop.sql @@ -0,0 +1,5 @@ +SELECT * from bench( +'SELECT count(*) +FROM arrivals_departures +WHERE stop_id = ''de:11000:900100001::4'' -- S+U Friedrichstr. (Berlin)' +); diff --git a/benchmark/connections_by_non_existent_stop.sql b/benchmark/connections_by_non_existent_stop.sql new file mode 100644 index 0000000..fb9242d --- /dev/null +++ b/benchmark/connections_by_non_existent_stop.sql @@ -0,0 +1,5 @@ +SELECT * from bench( +'SELECT count(*) +FROM connections +WHERE from_stop_id = ''definitely-non-existent''' +); diff --git a/benchmark/connections_by_stop.sql b/benchmark/connections_by_stop.sql new file mode 100644 index 0000000..e993f2b --- /dev/null +++ b/benchmark/connections_by_stop.sql @@ -0,0 +1,5 @@ +SELECT * from bench( +'SELECT count(*) +FROM connections +WHERE from_stop_id = ''de:11000:900100001::4'' -- S+U Friedrichstr. (Berlin)' +); diff --git a/benchmark/index.sql b/benchmark/index.sql index e61db27..589011c 100644 --- a/benchmark/index.sql +++ b/benchmark/index.sql @@ -64,12 +64,16 @@ LANGUAGE plpgsql; \i arrs_deps_by_station_and_time_seq_0.sql \i arrs_deps_by_stop_and_time.sql \i arrs_deps_by_trip_and_date.sql +\i arrs_deps_by_stop.sql +\i arrs_deps_by_non_existent_stop.sql \i arrs_deps_by_time.sql \i connections_by_route_name_and_time.sql \i connections_by_station_and_time.sql \i connections_by_station_and_time_seq_0.sql \i connections_by_stop_and_time.sql \i connections_by_trip_and_date.sql +\i connections_by_stop.sql +\i connections_by_non_existent_stop.sql \i connections_by_time.sql SELECT * FROM _benchmark; diff --git a/benchmark/run.sh b/benchmark/run.sh index f6ab544..ab1cc76 100755 --- a/benchmark/run.sh +++ b/benchmark/run.sh @@ -4,4 +4,4 @@ set -e set -o pipefail cd "$(dirname "$0")" -psql -q -b -f index.sql +psql -q -b --csv -f index.sql diff --git a/readme.md b/readme.md index 7a5fde8..f8134c2 100644 --- a/readme.md +++ b/readme.md @@ -286,23 +286,27 @@ For example, when querying all *absolute* departures at `de:11000:900120003` (*S With all use cases I could think of, `gtfs-via-postgres` is reasonably fast. If there's a particular kind of query that you think should be faster, please [open an Issue](https://github.com/public-transport/gtfs-via-postgres/issues/new)! -The following benchmarks were run with the [2022-07-01 VBB GTFS dataset](https://vbb-gtfs.jannisr.de/2022-07-01/) (41k `stops`, 6m `stop_times`, 207m arrivals/departures); All measurements are in milliseconds. +The following benchmarks were run with the [2022-07-01 VBB GTFS dataset](https://vbb-gtfs.jannisr.de/2022-07-01/) (41k `stops`, 6m `stop_times`, 207m arrivals/departures) on an M1 laptop; All measurements are in milliseconds. | query | avg | min | p25 | p50 | p75 | p95 | p99 | max | iterations | | - | - | - | - | - | - | - | - | - | - | -|
SELECT *
FROM stops
ORDER BY ST_Distance(stop_loc::geometry, ST_SetSRID(ST_MakePoint(9.7, 50.547), 4326)) ASC
LIMIT 100
| 16.35 | 16.314 | 16.33 | 16.33 | 16.35 | 16.4 | 16.67 | 16.755 | 100 | -|
SELECT *
FROM arrivals_departures
WHERE route_short_name = 'S1'
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 17.31 | 16.878 | 17.03 | 17.15 | 17.27 | 17.93 | 21.21 | 22.499 | 100 | -|
SELECT *
FROM arrivals_departures
WHERE station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 281.32 | 270.481 | 271.85 | 273.2 | 278.29 | 309.28 | 372.82 | 397.984 | 40 | -|
SELECT *
FROM arrivals_departures
WHERE station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
AND stop_sequence = 0
| 202.75 | 197.608 | 200.25 | 200.92 | 201.76 | 213.51 | 213.73 | 213.762 | 50 | -|
SELECT *
FROM arrivals_departures
WHERE stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 8.29 | 8.11 | 8.16 | 8.18 | 8.21 | 8.67 | 9.93 | 14.049 | 100 | -|
SELECT *
FROM arrivals_departures
WHERE trip_id = '168977951'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 2.17 | 2.126 | 2.14 | 2.14 | 2.15 | 2.33 | 2.52 | 3.085 | 100 | -|
SELECT *
FROM arrivals_departures
WHERE t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 1113.49 | 1099.137 | 1103.84 | 1108.57 | 1120.34 | 1137.23 | 1142.86 | 1144.273 | 10 | -|
SELECT *
FROM connections
WHERE route_short_name = 'S1'
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 88.59 | 84.752 | 85.17 | 85.37 | 95.56 | 96.69 | 101.01 | 107.993 | 100 | -|
SELECT *
FROM connections
WHERE from_station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 302.45 | 290.906 | 292.08 | 293.58 | 300.24 | 340.4 | 344.37 | 345.193 | 40 | -|
SELECT *
FROM connections
WHERE from_station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
AND from_stop_sequence = 0
| 226.6 | 222.491 | 224.11 | 225.21 | 226.67 | 235.45 | 239.91 | 242.461 | 50 | -|
SELECT *
FROM connections
WHERE from_stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 23.55 | 23.184 | 23.42 | 23.5 | 23.6 | 23.98 | 24.52 | 24.535 | 100 | -|
SELECT *
FROM connections
WHERE trip_id = '168977951'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 3.01 | 2.959 | 2.97 | 2.98 | 3.03 | 3.09 | 3.45 | 3.51 | 100 | -|
SELECT *
FROM connections
WHERE t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
ORDER BY t_departure
LIMIT 100
| 7072.81 | 6961 | 7017 | 7058 | 7134 | 7179 | 7187 | 7189 | 7 | +|
SELECT *
FROM stops
ORDER BY ST_Distance(stop_loc::geometry, ST_SetSRID(ST_MakePoint(9.7, 50.547), 4326)) ASC
LIMIT 100
| 16.84 | 16.421 | 16.74 | 16.77 | 16.81 | 17.25 | 20.03 | 20.631 | 100 | +|
SELECT *
FROM arrivals_departures
WHERE route_short_name = 'S1'
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 27.77 | 26.994 | 27.61 | 27.74 | 27.85 | 28.47 | 29.86 | 30.14 | 100 | +|
SELECT *
FROM arrivals_departures
WHERE station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 275.65 | 272.239 | 273.74 | 275.29 | 276.59 | 280.18 | 281.45 | 281.923 | 40 | +|
SELECT *
FROM arrivals_departures
WHERE station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
AND stop_sequence = 0
| 202.48 | 199.638 | 200.39 | 201.55 | 204 | 207.88 | 211.66 | 212.071 | 50 | +|
SELECT *
FROM arrivals_departures
WHERE stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 6.2 | 6.076 | 6.1 | 6.12 | 6.15 | 6.79 | 7.63 | 8.456 | 100 | +|
SELECT *
FROM arrivals_departures
WHERE trip_id = '168977951'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 2.14 | 2.041 | 2.06 | 2.14 | 2.15 | 2.26 | 2.53 | 4.114 | 100 | +|
SELECT count(*)
FROM arrivals_departures
WHERE stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
| 61.79 | 60.952 | 61.26 | 61.51 | 61.85 | 64.31 | 64.66 | 65.298 | 100 | +|
SELECT count(*)
FROM arrivals_departures
WHERE stop_id = 'definitely-non-existent'
| 2.08 | 2.047 | 2.06 | 2.06 | 2.07 | 2.11 | 2.31 | 2.451 | 100 | +|
SELECT *
FROM arrivals_departures
WHERE t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 1577.91 | 1555.598 | 1561.93 | 1572.38 | 1592.68 | 1604.32 | 1606.46 | 1606.992 | 10 | +|
SELECT *
FROM connections
WHERE route_short_name = 'S1'
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 85.27 | 78.838 | 80.98 | 82.99 | 91.25 | 93.18 | 94.78 | 94.899 | 100 | +|
SELECT *
FROM connections
WHERE from_station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 306.27 | 297.505 | 300.15 | 302.1 | 311.19 | 319.82 | 333.09 | 335.374 | 40 | +|
SELECT *
FROM connections
WHERE from_station_id = 'de:11000:900100001' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
AND from_stop_sequence = 0
| 231.07 | 224.655 | 229.2 | 230.86 | 231.86 | 239.84 | 247.15 | 253.035 | 50 | +|
SELECT *
FROM connections
WHERE from_stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
AND t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 12.6 | 12.084 | 12.35 | 12.46 | 12.67 | 13.45 | 15.35 | 15.992 | 100 | +|
SELECT *
FROM connections
WHERE trip_id = '168977951'
AND date > '2022-08-08' AND date <= '2022-08-09'
| 3.17 | 3.057 | 3.09 | 3.12 | 3.15 | 3.46 | 4.18 | 4.709 | 100 | +|
SELECT count(*)
FROM connections
WHERE from_stop_id = 'de:11000:900100001::4' -- S+U Friedrichstr. (Berlin)
| 92.47 | 91.159 | 91.56 | 92.17 | 92.78 | 94.72 | 96.47 | 96.574 | 100 | +|
SELECT count(*)
FROM connections
WHERE from_stop_id = 'definitely-non-existent'
| 18.35 | 17.877 | 18.02 | 18.12 | 18.44 | 19.31 | 20.66 | 21.05 | 100 | +|
SELECT *
FROM connections
WHERE t_departure >= '2022-08-09T07:10+02' AND t_departure <= '2022-08-09T07:30+02'
AND date > '2022-08-08' AND date <= '2022-08-09'
ORDER BY t_departure
LIMIT 100
| 9050.33 | 9001.322 | 9013.13 | 9033.42 | 9078.03 | 9119.54 | 9132.11 | 9135.253 | 7 | ## Related Projects