Page 1 of 1

TUniScript very slow

Posted: Thu 23 May 2013 18:45
by 99Percent
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?

Re: TUniScript very slow

Posted: Fri 24 May 2013 14:00
by DemetrionQ
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.