I am trying to insert many rows (~900) into a postgresql table using insert statements. I tried using the TUniQuery first but it doesn't allow multiple SQL statements, even separated with ;
I can successfully insert with TUniScript but it is exceedingly slow. It takes about 20 minutes, while executing the script via PGAdmin3 takes less than a second.
I am using Linux, Lazarus x64 Unidac version 4.1.5
What am I missing?
TUniScript very slow
-
DemetrionQ
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: TUniScript very slow
Hello.
For PostgreSQL TUniQuery cannot execute multiple SQL statements due to the specificity of the third protocol (it is set by default) on exchange with PostgreSQL Server - this protocol requires necessary query preparation, independently on whether the Prepare method was called or not. You have 2 ways of solving this problem:
- set the UnpreparedExecute property to True for TUniQuery via TUniQuery.SpecificOptions, this can be done in the following way:
- use the second version of the exchange protocol, this can be done using TUniConnection.SpecificOptions in the following way:
If you want to insert data into the table with the fastest speed, you can use the TUniLoader component in the following way:
- set the table name in the TUniLoader.TableName property;
- call the TUniLoader.CreateColumns method;
- write code for data loading to the TUniLoader.OnPutData application handle.
The detailed information about TUniLoader can be found in the UniDAC documentation.
For PostgreSQL TUniQuery cannot execute multiple SQL statements due to the specificity of the third protocol (it is set by default) on exchange with PostgreSQL Server - this protocol requires necessary query preparation, independently on whether the Prepare method was called or not. You have 2 ways of solving this problem:
- set the UnpreparedExecute property to True for TUniQuery via TUniQuery.SpecificOptions, this can be done in the following way:
Code: Select all
UniQuery1.SpecificOptions.Values['PostgreSQL.UnpreparedExecute'] := 'True';Code: Select all
UniConnection1.SpecificOptions.Values['PostgreSQL.ProtocolVersion'] := 'pv20';- set the table name in the TUniLoader.TableName property;
- call the TUniLoader.CreateColumns method;
- write code for data loading to the TUniLoader.OnPutData application handle.
The detailed information about TUniLoader can be found in the UniDAC documentation.