Description
Hi,
We have a communication server that handles a lot of connections (to/from vehicles).
The server issues a lot of SQL commands, mostly SELECT and UPDATE.
When updating the server from version 2.x (2.6.2) to 3.x (3.2.0), we experience that the performance is less than 50% of what it was before.
I just did some really basic benchmarks, which should highligt the problem.
The test just run a simple SELECT 1000 times and measures how long it takes.
3.2.0:
Elapsed: execute() 634 ms.
Elapsed: execute(QueryMode.simple) 186 ms.
2.6.2:
Elapsed query(): 230 ms.
Elapsed execute(): 193 ms.
The tests are run against localhost.
The biggest problem seems to be the new execute() command.
Any comments/ideas?
Source 2.6.2:
`void test() async {
PostgreSQLConnection conn =
PostgreSQLConnection('127.0.0.1', 5433, 'postgres', username: 'postgres', password: 'xxxxx');
await conn.open();
String q = "SELECT 1,now(),'TEST'";
int nLoops = 1000;
Stopwatch s = Stopwatch();
s.start();
for (int i = 0; i < nLoops; i++) {
PostgreSQLResult res = await conn.query(q);
}
print('Elapsed query(): ${s.elapsedMilliseconds} ms.');
s.reset();
for (int i = 0; i < nLoops; i++) {
int n = await conn.execute(q);
}
print('Elapsed execute(): ${s.elapsedMilliseconds} ms.');
}`
Source 3.2.0:
`void test() async {
final ConnectionSettings connectionSettings =
ConnectionSettings(applicationName: 'vehicleservice_autodispatch', sslMode: SslMode.disable);
Connection conn = await Connection.open(
Endpoint(host: '127.0.0.1', database: 'postgres', port: 5433, username: 'postgres', password: 'xxxxx'),
settings: connectionSettings);
String q = "SELECT 1,now(),'TEST'";
int nLoops = 1000;
Stopwatch s = Stopwatch();
s.start();
for (int i = 0; i < nLoops; i++) {
Result res = await conn.execute(q);
}
print('Elapsed: execute() ${s.elapsedMilliseconds} ms.');
s.reset();
for (int i = 0; i < nLoops; i++) {
Result res = await conn.execute(q, queryMode: QueryMode.simple);
}
print('Elapsed: execute(QueryMode.simple) ${s.elapsedMilliseconds} ms.');
}
`