idea to improve performance
Posted: 20.02.2007, 17:22
I got an idea to improve performance when doing a lot of inserting into the database. The following code in ZDbcCachedResultSet will execute a query for every row being inserted just to get the row default values. If doing bulk inserts into the same table, it shouldn't be necessary to get these default values from the database for every row. The default values could be cached in a result set for re-use.
From the profiling i've done, it should improve performance quite a bit when inserting a lot into the same table, since it is spending just as long calculating the row defaults as it is actually posting the row inserts.
[delphi]
procedure TZAbstractCachedResultSet.InternalCommitRow(AIndex: Integer);
begin
...
{ Updates default field values. }
if NewRowAccessor.RowBuffer.UpdateType = utInserted then
CalculateRowDefaults(NewRowAccessor);
...
[/delphi]
If i write the feature to cache the default values, would anyone care to have this incorporated into Zeos? How would you prefer this to be written?
From the profiling i've done, it should improve performance quite a bit when inserting a lot into the same table, since it is spending just as long calculating the row defaults as it is actually posting the row inserts.
[delphi]
procedure TZAbstractCachedResultSet.InternalCommitRow(AIndex: Integer);
begin
...
{ Updates default field values. }
if NewRowAccessor.RowBuffer.UpdateType = utInserted then
CalculateRowDefaults(NewRowAccessor);
...
[/delphi]
If i write the feature to cache the default values, would anyone care to have this incorporated into Zeos? How would you prefer this to be written?