Fast Inserts / Batch Inserts

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
barbaro
Posts: 5
Joined: Fri 17 Dec 2004 15:43

Fast Inserts / Batch Inserts

Post by barbaro » Fri 17 Dec 2004 15:45

Is there anyway to speedup inserts?

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Fast Inserts / Batch Inserts

Post by Ikar » Mon 20 Dec 2004 15:45

If you need to insert great number of records into database the most quickest way is packet insertion of records. Set a query

Code: Select all

SQL.Text := 
  'INSERT ...;'#$D#$A + 
  'INSERT ...;'#$D#$A + 
  ...
On execution of this query it will be passed to the server by a single packet.

Also it would help to increase MSConnection.Options.PacketSize.

barbaro
Posts: 5
Joined: Fri 17 Dec 2004 15:43

Re: Fast Inserts / Batch Inserts

Post by barbaro » Mon 20 Dec 2004 18:31

Any measurements of how fast can it be?

Ikar wrote:If you need to insert great number of records into database the most quickest way is packet insertion of records. Set a query

Code: Select all

SQL.Text := 
  'INSERT ...;'#$D#$A + 
  'INSERT ...;'#$D#$A + 
  ...
On execution of this query it will be passed to the server by a single packet.

Also it would help to increase MSConnection.Options.PacketSize.

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Fast Inserts / Batch Inserts

Post by Ikar » Tue 21 Dec 2004 09:12

It greatly depends on a lot of parameters. Speed-up can reach tens of times. Speed/Performance will increase with lessening data in the single row.

barbaro
Posts: 5
Joined: Fri 17 Dec 2004 15:43

Packetsize

Post by barbaro » Tue 21 Dec 2004 11:35

Thanks for your replies,
Another related question:
What happens if the sql.text size is larger than the packet size?
How can i calculate the actual size of the data being sent to the server?

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Packetsize

Post by Ikar » Fri 24 Dec 2004 11:43

> What happens if the sql.text size is larger than the packet size?

The query will be divided into several packets.

> How can i calculate the actual size of the data being sent to the server?[/

OLE DB and SDAC don't provide this functionality.

Post Reply