[Mono-list] Batch inserts with ADO.NET

Fredrik Hedberg fredrik.hedberg@hedbergs.com
Sun, 23 May 2004 13:52:15 +0200


Hi,

Par example:

command.Text = "INSER INTO ...";
command.Prepare();

for (int i = 0; i < 10000; i++)
{
	// Add some parameter data
	command.executeNonQuery();
}

The problem is, this still executes queries and checks results from the
database engine (in my case over the network) for each and every insert.
This slows the process considerably and while the JDBC add- and
executeBatch method below does about 80000 inserts per second, code like
the above snippet only does about 4000 with my current setup.

Thanks for you input.

/Fred

On Sun, 2004-05-23 at 13:34, Carlos Guzmán Álvarez wrote:
> Hello:
> 
> >PreparedStatement statement = connection.prepareStatement("INSERT
> >INTO....");
> >                        
> >            for (int i = 0; i < 1000; i++)
> >            {
> >                    statement.setInt(1,rand.nextInt());
> >                    statement.addBatch();
> >            }
> >            statement.executeBatch();
> >
> Maybe you can use parametrized querys and the
> XxCommand.Prepare method ??
> 
> 
> 
> 
> --
> Best regards
> 
> Carlos Guzmán Álvarez
> Vigo-Spain
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list