Search code examples
delphifirebirddelphi-11-alexandriafirebird-4.0

Delphi FireDac Firebird 4.0 Connection Pooling


I'm testing Firedac (Delphi 11 Update1) and Firebird 4.0 (Latest) for a rest API server project. I found the connection pooling technic in Firebird documentation as a possibility and also in FireDac documentation. In my test application, I can enable and disable the FireDac Pooling, which has a significant difference, so it's OK.

But Firebird 4.0 Connection pool enabled and disabled no difference. Is this thing working in Delphi, Firedac or what do I miss or don't understand?

In Firebird.conf: ExtConnPoolSize = 20, and extConnPoolLifeTime = 10.

On the Delphi side, I wrote a mini-testing code, created an "X" thread and ran them, and measure them. In the thread: create Connection and one query, connect to the database via FDManager, run the query, fetch all, and free. I can run the code with Firebird 2.5 for control, and Firebird 4.0.

Configuration:

  • Firebird 2.5.9 super 64 bit.
  • Firebird 4.0, super 64 bit. no WireCompression, AuthServer = Srp, Srp256
  • Local usage via tcpip.

Results:

Firebird 2.5 
32Bit Client
Full Run count: 100
ThreadCount:1
PeakCount:0
Avarage Time: 168
   min: 15
   max: 334

Firebird 4.0 
32Bit Client
Full Run count: 100
ThreadCount:1
PeakCount:0
Avarage Time: 44
   min: 31
   max: 78

Firebird 2.5 
32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:3
Avarage Time: 19
   min: 0
   max: 208

Firebird 4.0 FBDatabasePool on 32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:4
Avarage Time: 21
   min: 15
   max: 47

Firebird 4.0 FBDatabasePool OFF
32Bit Client
Full Run count: 100
ThreadCount:4
PeakCount:6
Avarage Time: 25
   min: 15
   max: 94

 


Solution

  • The connection pool introduced in Firebird 4.0 is a server-side connection pool used for connections the server itself creates to other databases. This concerns for example connections in PSQL execute statement ... on external. It has no effects client-side, like your Delphi application (other than that queries that invoke PSQL code which use external connections may run slightly faster).

    In other words, that you don't observe any performance improvements when enabling the Firebird server-side connection pool is entirely expected for your setup.

    If you need a client-side connection pool, you need to use an appropriate library or component which provides client-side connection pooling, like FireDAC in your example.