Rapidly Use Delphi FireDAC In A Multithreaded Environment With The FireDAC.Pooling Sample
This example utilizes the Use Connection Definition drop-down menu to choose an association definition.
In a multithreaded application, where each string begins, sets up an association, plays out a specific short errand, and deliveries the association, the monotonous association foundations may prompt execution debasement over the entire framework. To keep away from this, the application can utilize the association pooling.
This application shows the distinction of time utilized when utilizing pooling to set up numerous associations with an information base.
You can find the TFDConnection\Pooling sample project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
- Object Pascal\DataBase\FireDAC\Samples\Comp Layer\TFDConnection\Pooling.
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Snap Run to execute mutiple strings that set up an association with the information base and perform SQL inquiries on it. To empower pooling, select Run pooled before clicking Run.
The Total executions and the Total time marks show the quantity of executed SQL inquiries and the measure of time utilized. The time is extensively second rate when utilizing pooling.
How to Use the Sample
- Navigate to the location given above and open:
- Delphi: Pooling.dproj
- Press F9 or choose Run > Run.
- Select a connection definition from the Use Connection Definition drop-down menu. Once a connection is selected the Run button is enabled.
- Select Run pooled to use pooling.
- Click Run to start creating the connections to the database. It executes 10 threads to the database.
- Use Connection Definition drop-down menu:
The menu shows all the connections defined on the file at C:\Users\Public\Documents\Embarcadero\Studio\FireDAC\FDConnectionsDefs.ini.
- Run button:
When clicked, the sample starts 10 threads connecting to the database. It uses the TFDCustomManager.ConnectionDefs property from a TFDManager to access the connection definition selected from the Use Connection Definition drop-down menu.
The standard simplification is to create and use for each thread a dedicated connection object working with the database. In this case, no additional serialization is required.
- Run pooled check box:
At the point when this alternative is chosen, the Pooled contention of the association setting is set to True. The association pooling can be empowered uniquely for a persevering or private association definition by setting Pooled to True.
Information base association pooling is a technique used to keep data set associations open so they can be reused by others. Opening an information base association is a costly activity, so pooling keeps the associations dynamic so that, when an association is later mentioned, one of the dynamic ones is utilized in inclination to opening another.
The connection beneath will divert you legitimately to the first post of the example: