How to optimize this codding
Moderators: gto, EgonHugeist
-
- Fresh Boarder
- Posts: 15
- Joined: 13.01.2009, 09:20
How to optimize this codding
Hi
With delphi 2007, i have lot of Insert commands to execute
I do something like this:
var
Connection: IZConnection;
Statement: IZStatement;
...
Statement:= Connection.CreateStatement;
Statement.ExecuteQuery(sqltosend.Text);
Statement.Close;
...
sqltosend is a StringList containing more or less 80 000 Insert query !
How to configure the Connection and the Statement to have this command the fastest as possible ?
(I mean autocommit, and all other parameters)
Thanks a lot
With delphi 2007, i have lot of Insert commands to execute
I do something like this:
var
Connection: IZConnection;
Statement: IZStatement;
...
Statement:= Connection.CreateStatement;
Statement.ExecuteQuery(sqltosend.Text);
Statement.Close;
...
sqltosend is a StringList containing more or less 80 000 Insert query !
How to configure the Connection and the Statement to have this command the fastest as possible ?
(I mean autocommit, and all other parameters)
Thanks a lot
-
- Fresh Boarder
- Posts: 15
- Joined: 13.01.2009, 09:20
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
andresayang,
I'm afraid you have the most optimal setting when sending the sql stringlist as one statement. Normally, even with autocommit, there's only one commit in your case.
You could consider splitting the script into smaller blocks with a commit in between if too big transactions slow down your database server, but I think that depends on the server you're using.
Mark
I'm afraid you have the most optimal setting when sending the sql stringlist as one statement. Normally, even with autocommit, there's only one commit in your case.
You could consider splitting the script into smaller blocks with a commit in between if too big transactions slow down your database server, but I think that depends on the server you're using.
Mark
-
- Fresh Boarder
- Posts: 15
- Joined: 13.01.2009, 09:20
-
- Fresh Boarder
- Posts: 15
- Joined: 13.01.2009, 09:20
Sorry, I am working with Postgres !manz wrote:dear andresayang
you may optimize your mysql server configuration to handling it with the good chosen engine ... such as InnoDB.
Manz
But I started with Zeoslib, my small soft is working perfectly for what i want to do with it.
The normal way of working is with Stringlist containing around 500 insert queries, so It is not "so slow". I have the soft and a database on my laptop for development and what I do with it is not exactly the "normal way" of working, so I have bigger file to Import / Exports (much more easy to optimize the code for speed when working on huge files).
I only wanted to have a small explanation on what effect of the connection parameters on the speed of the transactions.
Rgds
I think the most important parameter for speed is Autocommit. if you set Autocommit := True every insert statement you execute starts its own transaction, so the database need to setup a transaction enviroment for every statement. Setting Autocommit:= False before the bulk insert implies just one transaction for the database.
Using triggers on tables is another source of delay on bulk inserts.
if you didn't do yet, please check postgres manual for transactions and triggers topics.
sorry my poor english X)
Using triggers on tables is another source of delay on bulk inserts.
if you didn't do yet, please check postgres manual for transactions and triggers topics.
sorry my poor english X)
-
- Fresh Boarder
- Posts: 15
- Joined: 13.01.2009, 09:20