You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-05 00:28:52 +02:00
Fix PostgreSQL query performance for large datasets.
The asynchronous logic used to implement the query timeout was misusing PQisBusy(), which caused the wait handler to throttle the consumption of command results. It could introduce a large delay on a query up to `db-timeout` because of the back-off sequence. Following the recommendation of libpq, fix by polling the client socket for data availability and then continue consuming results and checking for command busyness.
This commit is contained in:
@ -6,6 +6,7 @@ Postgres Client
|
||||
#include <libpq-fe.h>
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/io/fd.h"
|
||||
#include "common/log.h"
|
||||
#include "common/wait.h"
|
||||
#include "postgres/client.h"
|
||||
@ -198,7 +199,7 @@ pgClientQuery(PgClient *const this, const String *const query, const PgClientQue
|
||||
PQconsumeInput(this->connection);
|
||||
busy = PQisBusy(this->connection);
|
||||
}
|
||||
while (busy && waitMore(wait));
|
||||
while (busy && fdReadyRead(PQsocket(this->connection), waitRemains(wait)));
|
||||
|
||||
// If the query is still busy after the timeout attempt to cancel
|
||||
if (busy)
|
||||
|
Reference in New Issue
Block a user