From 3caffb49e3084d3f5153df958010bb1241671a26 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Sun, 24 Nov 2024 19:06:57 -0800 Subject: [PATCH] start timing the pg queries in aspen --- src/aspen/import_alpenrose.rs | 8 ++++---- src/birch/nearby_departures.rs | 18 +++++++----------- src/maple/gtfs_process.rs | 26 ++++++++++++-------------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/src/aspen/import_alpenrose.rs b/src/aspen/import_alpenrose.rs index a7db822..bde23ed 100644 --- a/src/aspen/import_alpenrose.rs +++ b/src/aspen/import_alpenrose.rs @@ -8,9 +8,7 @@ use ahash::{AHashMap, AHashSet}; use catenary::aspen_dataset::*; use catenary::postgres_tools::CatenaryPostgresPool; use compact_str::CompactString; -use diesel::ExpressionMethods; -use diesel::QueryDsl; -use diesel::SelectableHelper; +use diesel::prelude::*; use diesel_async::RunQueryDsl; use gtfs_realtime::FeedMessage; use scc::HashMap as SccHashMap; @@ -712,6 +710,8 @@ pub async fn new_rt_data( } } } + + println!("Finished processing {} chateau took {:?} for route lookup, {:?} for trips, {:?} for itins", chateau_id,routes_query_elapsed, trip_duration, itin_lookup_duration); } //Insert data back into process-wide authoritative_data_store @@ -750,7 +750,7 @@ pub async fn new_rt_data( } } - println!("Updated Chateau {}", chateau_id,); + println!("Updated Chateau {}", chateau_id); Ok(true) } diff --git a/src/birch/nearby_departures.rs b/src/birch/nearby_departures.rs index 99a398c..59b718e 100644 --- a/src/birch/nearby_departures.rs +++ b/src/birch/nearby_departures.rs @@ -28,12 +28,9 @@ use catenary::EtcdConnectionIps; use chrono::TimeZone; use compact_str::CompactString; use diesel::dsl::sql; -use diesel::dsl::sql_query; -use diesel::query_dsl::methods::FilterDsl; -use diesel::query_dsl::methods::SelectDsl; +use diesel::prelude::*; +use diesel::sql_query; use diesel::sql_types::Bool; -use diesel::ExpressionMethods; -use diesel::SelectableHelper; use diesel_async::RunQueryDsl; use futures::stream::futures_unordered; use futures::stream::FuturesUnordered; @@ -266,12 +263,11 @@ pub async fn nearby_from_coords( let where_query_for_stops = format!("ST_DWithin(gtfs.stops.point, 'SRID=4326;POINT({} {})', {}) AND allowed_spatial_query = TRUE", query.lon, query.lat, spatial_resolution_in_degs); - let stops: diesel::prelude::QueryResult> = - catenary::schema::gtfs::stops::dsl::stops - .filter(sql::(&where_query_for_stops)) - .select(catenary::models::Stop::as_select()) - .load::(conn) - .await; + let stops: QueryResult> = catenary::schema::gtfs::stops::dsl::stops + .filter(sql::(&where_query_for_stops)) + .select(catenary::models::Stop::as_select()) + .load::(conn) + .await; let end_stops_duration = start_stops_query.elapsed(); diff --git a/src/maple/gtfs_process.rs b/src/maple/gtfs_process.rs index 5de9fb9..452ec6a 100644 --- a/src/maple/gtfs_process.rs +++ b/src/maple/gtfs_process.rs @@ -77,23 +77,21 @@ pub async fn gtfs_process_feed( println!("Filtered TTC Subway"); gtfs.print_stats(); gtfs - }, + } "f-uc~irvine~anteater~express" => { let mut gtfs = gtfs; - gtfs.feed_info = vec![ - gtfs_structures::FeedInfo { - name: "TransLoc, Inc.".to_string(), - url: "https://transloc.com".to_string(), - lang: "en".to_string(), - start_date: Some(chrono::NaiveDate::from_ymd_opt(2024, 07, 10).unwrap()), - end_date: Some(chrono::NaiveDate::from_ymd_opt(2099, 12, 31).unwrap()), - version: None, - default_lang: Some("en".to_string()), - contact_email: None, - contact_url: None, - } - ]; + gtfs.feed_info = vec![gtfs_structures::FeedInfo { + name: "TransLoc, Inc.".to_string(), + url: "https://transloc.com".to_string(), + lang: "en".to_string(), + start_date: Some(chrono::NaiveDate::from_ymd_opt(2024, 07, 10).unwrap()), + end_date: Some(chrono::NaiveDate::from_ymd_opt(2099, 12, 31).unwrap()), + version: None, + default_lang: Some("en".to_string()), + contact_email: None, + contact_url: None, + }]; gtfs }