Hi Carlos,

>Are you using Transactions ?? If yes how ?? You should start a 
>transaction before doing the Update, and assing that transaction to the 
>insert command if not if you have 25000 rows there will be 25000 
>transactions ( one per command ).

I've now been experimenting with to approaches. The first approach I assign
a transaction to the insert command as you suggested. 25000 inserts now take
14 seconds.

In the other approach I do a batch execution, which takes 11 seconds.

These results are much more acceptable, but are still 2-3 times slower than
in C++ using the IBPP library (25000 INSERTs takes only 5 seconds).

I have added my code for the two approaches - am I doing something wrong?


Alex Jankowski



First approach:

FbConnection connection = new FbConnection(connectionString);
connection.Open();
FbDataAdapter dataAdapter = new FbDataAdapter("SELECT * FROM TestTable",
connection);
            
FbCommandBuilder commandBuilder = new FbCommandBuilder(dataAdapter);
FbTransaction transaction = connection.BeginTransaction();
dataAdapter.SelectCommand.Transaction = transaction;
dataAdapter.InsertCommand = commandBuilder.GetInsertCommand();
dataAdapter.InsertCommand.Transaction = transaction;
dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand();
dataAdapter.UpdateCommand.Transaction = transaction;
dataAdapter.DeleteCommand = commandBuilder.GetDeleteCommand();
dataAdapter.DeleteCommand.Transaction = transaction;
            
DataTable dataTable = new DataTable();
dataAdapter.Fill(dataTable);

for (int i = 1025000; i < 1050000; i++)
   dataTable.Rows.Add(i, "FirstName" + i, "LastName" + i);

dataAdapter.Update(dataTable);
transaction.Commit();
connection.Close();


Second approach:

FbConnection connection = new FbConnection(connectionString);
connection.Open();
FbBatchExecution batch = new FbBatchExecution(connection);

for(int i = 1050000; i < 1075000; i++)
        batch.SqlStatements.Add("INSERT INTO TestTable VALUES(" + i + ",
'FirstName" + i + "', 'LastName" + i + "'); ");
           
batch.Execute(false);
connection.Close();




-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Firebird-net-provider mailing list
Firebird-net-provider@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/firebird-net-provider

Reply via email to