Re: ADO Performance question
- From: "Stephen Howe" <stephenPOINThoweATtns-globalPOINTcom>
- Date: Thu, 27 Oct 2005 15:44:36 +0100
> I would say it depends what you're trying to do, although I wouldn't
expect
> there to be much difference performance-wise. The difference comes from
ease
> of use.
>
> I would prefer the mechanism of using a recordset rather than constructing
> sql to use in the command text for the following reasons:
> 1) A recordset is typed so the data you are entering is validated before
you
> perform a round-trip to the database
> 2) Your updates are encapsulated in a recordset.
> 3) If you are constructing SQL on the fly (concatenation of strings) there
> is the chance of a syntactic error which will only be found at run-time.
> 4) The SQL should be placed inside a transaction.
We have been using this approach for the past 5 years with ADO and SQL
Server as the back end.
Basically we construct an empty Recordset (using SELECT
field1,field2,..,fieldN FROM mytable WHERE 0=1), proceed to populate it
using RecordBinding and then UpdateBatch(). All records are INSERTed. It
works but it is not wonderfully fast.
But I have asked myself, "Is this as fast as it gets?" and never been
satisfied.
And also I know that the Recordset has certain overheads.
It records each field 3 times (OriginalValue, UnderlyingValue and Value).
I want to d
I have tried Stored Procedures and also SQL INSERT statements via Command
object.
But this turned out to be slower.
But after reading a few messages by William Vaughn, I realised how it can be
improved.
Where the Stored Procedures/SQL INSERT speed goes is the round trip to the
server of an individual row. The SQL Server provider allows multiple
statements. You want to batch them up. So essentially you want to multiple
INSERTs - same as what UpdateBatch() does on watching the profiler without
the Recordset overhead.
So my guess would be for max ADO performance (without going DTS/BulkCopy
approach) in pseudocode
IF NRowsToInsert < SomeADOTheshold
' Do Connection Execute with individual Rows
ELSE
'Construct Command Object with say 32 Rows and (32*NFields ?) as temp
procedure
'Load, execute NRowsToInsert / 32 times
'Construct Command Object with NRowsToInsert remainder 32 and
(32*NFields ?) as temp
'Load, execute NRowsToInsert remainder 32
END IF
Stephen Howe
.
- References:
- ADO Performance question
- From: Pushkar
- ADO Performance question
- Prev by Date: Problem Passing RecordSet as byRef Parameter in Com/ASP Environment
- Next by Date: Re: ADO Performance question
- Previous by thread: ADO Performance question
- Next by thread: Re: ADO Performance question
- Index(es):
Relevant Pages
|
|