From 2474af6a865152e01cb748a12f51331d616444ea Mon Sep 17 00:00:00 2001 From: Valentyn Kit Date: Fri, 28 Aug 2026 14:58:36 +0300 Subject: [PATCH] docs: clarify `Pool::size` and `Pool::num_idle` `num_idle` was documented as returning connections "active and idle", which reads as active plus idle. It only counts idle ones. `size` was documented as "currently active. This includes idle connections" which is incomplete: `try_increment_size()` bumps the counter before the connection is established, so connections still being opened are counted too. --- sqlx-core/src/pool/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sqlx-core/src/pool/mod.rs b/sqlx-core/src/pool/mod.rs index f11ff1d76a..a59a71778d 100644 --- a/sqlx-core/src/pool/mod.rs +++ b/sqlx-core/src/pool/mod.rs @@ -531,12 +531,14 @@ impl Pool { self.0.close_event() } - /// Returns the number of connections currently active. This includes idle connections. + /// Returns the total number of connections owned by the pool. + /// + /// This includes idle connections and ones still being opened. pub fn size(&self) -> u32 { self.0.size() } - /// Returns the number of connections active and idle (not in use). + /// Returns the number of idle connections (not checked out). pub fn num_idle(&self) -> usize { self.0.num_idle() }