TUniScript very slow

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

TUniScript very slow

Post by 99Percent » Thu 23 May 2013 18:45

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?

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: TUniScript very slow

Post by DemetrionQ » Fri 24 May 2013 14:00

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:

Code: Select all

  UniQuery1.SpecificOptions.Values['PostgreSQL.UnpreparedExecute'] := 'True';
 - use the second version of the exchange protocol, this can be done using TUniConnection.SpecificOptions in the following way:

Code: Select all

  UniConnection1.SpecificOptions.Values['PostgreSQL.ProtocolVersion'] := 'pv20';
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.

Post Reply