From d65548400b8479fd515c93e3589cdc71eb6ca11e Mon Sep 17 00:00:00 2001 From: Sai Asish Y Date: Sun, 24 May 2026 21:26:38 -0700 Subject: [PATCH] fix: report query_time in microseconds to match PgBouncer SHOW STATS reported total_query_time and avg_query_time in milliseconds while PgBouncer reports the same fields in microseconds. Change the elapsed duration calculation from as_millis() to as_micros() so the values are consistent with PgBouncer and with wait_time, which was already stored in microseconds. Fixes #810 Signed-off-by: Sai Asish Y --- src/client.rs | 2 +- src/stats/server.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.rs b/src/client.rs index c72e9d2a..82164dc1 100644 --- a/src/client.rs +++ b/src/client.rs @@ -2017,7 +2017,7 @@ where // Report query executed statistics. client_stats.query(); server.stats().query( - Instant::now().duration_since(query_start).as_millis() as u64, + Instant::now().duration_since(query_start).as_micros() as u64, self.server_parameters.get_application_name(), ); diff --git a/src/stats/server.rs b/src/stats/server.rs index 5d255994..af11779c 100644 --- a/src/stats/server.rs +++ b/src/stats/server.rs @@ -176,10 +176,10 @@ impl ServerStats { } /// Report a query executed by a client against a server - pub fn query(&self, milliseconds: u64, application_name: &str) { + pub fn query(&self, microseconds: u64, application_name: &str) { self.set_application(application_name.to_string()); self.address.stats.query_count_add(); - self.address.stats.query_time_add(milliseconds); + self.address.stats.query_time_add(microseconds); self.query_count.fetch_add(1, Ordering::Relaxed); }