From 836ee631dfe3b9257fd8c30c9de2d082147959b1 Mon Sep 17 00:00:00 2001 From: GroovieGermanikus Date: Tue, 25 Jun 2024 20:48:28 +0200 Subject: [PATCH] disable: synchronous_commit and commit_delay --- src/main.rs | 2 +- src/postgres.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 2277cf0..ba2a601 100644 --- a/src/main.rs +++ b/src/main.rs @@ -383,7 +383,7 @@ async fn main() -> anyhow::Result<()> { .collect_vec(); let mut block_senders = vec![]; - info!("Starting {} block senders"); + info!("Starting {} block senders", NUM_BLOCK_SENDERS); for i in 1..=NUM_BLOCK_SENDERS { let s = postgres::Postgres::new_with_workmem(i) .await diff --git a/src/postgres.rs b/src/postgres.rs index 0e29a55..da0da69 100644 --- a/src/postgres.rs +++ b/src/postgres.rs @@ -194,6 +194,18 @@ impl PostgresSession { info!("Disable parallel postgres workers"); } + pub async fn relax_commit_settings(&self) { + self.client + .execute("SET synchronous_commit TO 'off'", &[]) + .await + .unwrap(); + self.client + .execute("SET commit_delay TO 1000", &[]) + .await + .unwrap(); + info!("Configured synchronous_commit and commit_delay"); + } + pub async fn drop_temp_table(&self, table: String) -> anyhow::Result<()> { self.client .execute(format!("drop table if exists {};", table).as_str(), &[]) @@ -1307,6 +1319,7 @@ impl Postgres { let session = PostgresSession::new(nb).await.unwrap(); let session = Arc::new(session); session.configure_work_mem().await; + session.disable_postgres_workers().await; Self { session } }