Skip to content

Commit

Permalink
Merge pull request #2131 from joto/connections-sync-commit
Browse files Browse the repository at this point in the history
Disable synchronous commit on all connections
  • Loading branch information
lonvia authored Feb 3, 2024
2 parents 95f330f + dac98d6 commit 68eae3f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/db-copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,6 @@ void db_copy_thread_t::thread_t::operator()()
try {
m_conn = std::make_unique<pg_conn_t>(m_connection_params, "copy");

// Let commits happen faster by delaying when they actually occur.
m_conn->exec("SET synchronous_commit = off");

// Disable sequential scan on database tables in the copy threads.
// The copy threads only do COPYs (which are unaffected by this
// setting) and DELETEs which we know benefit from the index. For
Expand Down
1 change: 0 additions & 1 deletion src/flex-table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ void table_connection_t::connect(connection_params_t const &connection_params)

m_db_connection =
std::make_unique<pg_conn_t>(connection_params, "out.flex.table");
m_db_connection->exec("SET synchronous_commit = off");
}

static void enable_check_trigger(pg_conn_t const &db_connection,
Expand Down
5 changes: 5 additions & 0 deletions src/pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ pg_conn_t::pg_conn_t(connection_params_t const &connection_params,
if (!get_logger().debug_enabled()) {
exec("SET client_min_messages = WARNING");
}

// Disable synchronous_commit on all connections. For some connections it
// might not matter, especially if they read only, but then it doesn't
// hurt either.
exec("SET synchronous_commit = off");
}

void pg_conn_t::close()
Expand Down
2 changes: 0 additions & 2 deletions src/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ void table_t::sync() { m_copy.sync(); }
void table_t::connect()
{
m_sql_conn = std::make_unique<pg_conn_t>(m_connection_params, "out.pgsql");
//let commits happen faster by delaying when they actually occur
m_sql_conn->exec("SET synchronous_commit = off");
}

void table_t::start(connection_params_t const &connection_params,
Expand Down

0 comments on commit 68eae3f

Please sign in to comment.