From c33490b64ba2ae1aea5a34e8d82da74684d3c0b5 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Wed, 31 Jan 2024 12:35:28 +0100 Subject: [PATCH] narrow resources cleared in clear_session --- src/postgres.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/postgres.rs b/src/postgres.rs index f833f3b..f615111 100644 --- a/src/postgres.rs +++ b/src/postgres.rs @@ -171,8 +171,16 @@ impl PostgresSession { } pub async fn clear_session(&self) { + // see https://www.postgresql.org/docs/current/sql-discard.html + // CLOSE ALL -> drop potental cursors + // RESET ALL -> we do not want (would reset work_mem) + // DEALLOCATE -> would drop prepared statements which we do not use ATM + // DISCARD PLANS -> we want to keep the plans + // DISCARD SEQUENCES -> we want to keep the sequences self.client - .execute("DISCARD ALL", &[]) + .batch_execute(r#" + DISCARD TEMP; + CLOSE ALL;"#) .await .unwrap(); debug!("Clear postgres session");