From fa4930b839187ecc3b3234eba9f01ea411a5fd69 Mon Sep 17 00:00:00 2001 From: Timothy Quilling Date: Tue, 9 Dec 2025 15:27:37 -0500 Subject: [PATCH] chore: add debug timings --- parakeet/src/db/feeds.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/parakeet/src/db/feeds.rs b/parakeet/src/db/feeds.rs index 1c4d3de6..f38a697e 100644 --- a/parakeet/src/db/feeds.rs +++ b/parakeet/src/db/feeds.rs @@ -227,11 +227,14 @@ pub async fn get_author_feed( ) }; + let posts_query_start = std::time::Instant::now(); let posts: Vec = diesel::sql_query(&posts_sql) .load(conn) .await?; - let posts_time = query_start.elapsed().as_secs_f64() * 1000.0; - tracing::debug!(" → Posts query: {:.1} ms ({} rows)", posts_time, posts.len()); + let posts_time = posts_query_start.elapsed().as_secs_f64() * 1000.0; + if posts_time > 10.0 { + tracing::info!(" → Posts query: {:.1} ms ({} rows)", posts_time, posts.len()); + } // Query 2: Get reposts metadata only (no join to posts yet) // OPTIMIZATION: Split into two steps to reduce chunk checks from N×362 to 1×362 @@ -272,7 +275,9 @@ pub async fn get_author_feed( .load(conn) .await?; let reposts_metadata_time = reposts_start.elapsed().as_secs_f64() * 1000.0; - tracing::debug!(" → Reposts metadata query: {:.1} ms ({} rows)", reposts_metadata_time, repost_metadata.len()); + if reposts_metadata_time > 10.0 { + tracing::info!(" → Reposts metadata query: {:.1} ms ({} rows)", reposts_metadata_time, repost_metadata.len()); + } // Step 2b: Unified post lookup with UNNEST+LATERAL (single chunk check) // This batches all repost lookups into ONE query instead of N LATERAL joins @@ -316,7 +321,9 @@ pub async fn get_author_feed( }; let unified_time = unified_start.elapsed().as_secs_f64() * 1000.0; - tracing::debug!(" → Unified post lookup: {:.1} ms ({} complete posts)", unified_time, complete_posts.len()); + if unified_time > 10.0 { + tracing::info!(" → Unified post lookup: {:.1} ms ({} complete posts)", unified_time, complete_posts.len()); + } // Reconstruct reposts, filtering for only those pointing to complete posts let reposts: Vec = repost_metadata -- 2.54.0