Bizarre slowdown in updating Access table
- From: "Glenn Alcott" <galcott@xxxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 18:04:24 -0500
I have a D7 app using an Accesss back end via ADO, and I need to do some
rather complex data manipulation to produce a temporary table
that will be used as the data source for a TeeChart graph. I am having a
mysterious performance problem where the time needed to
execute one section of the code increases dramatically (almost
exponentially) as the size of this table grows.
The table is first populated by an INSERT INTO query and this works fine and
with acceptable speed. Then I need to do some updating
that can't be done with a query (it would require an UPDATE query with a
subquery, which Access doesn't allow). So I use the following
simple loop to update a couple of fields. When the table has 20 records,
this runs in 0.8 seconds. When it has 100 records, it takes
16 seconds (5 times as many records, but 20 times slower). When it goes up
to 600 records it takes over 10 minutes, which is more
than 1 second per record. I am using a TADOTable and have tried different
settings for CursorType, CursorLocation and TableDirect
to no avail. In many years of working with Delphi and Access I have never
seen anything like this, and am totally stumped.
Glenn
var RunningTotal: double; PrevNumContracts: integer;
RunningTotal:=0;
PrevNumContracts:=1;
with DataModule1.tblGraphTemp do begin
Open;
First;
while not EOF do begin
Edit;
DataModule1.tblGraphTempCompoundedPeriodProfit.AsFloat:=DataModule1.tblGraph
TempPeriodProfit.AsFloat*PrevNumContracts;
RunningTotal:=RunningTotal+DataModule1.tblGraphTempCompoundedPeriodProfit.As
Float;
DataModule1.tblGraphTempCompoundedRunningTotal.AsFloat:=RunningTotal;
PrevNumContracts:=DataModule1.tblGraphTempNumContracts.AsInteger;
Next;
end;
end;
.
- Prev by Date: Create Database in MS Access. & set properties of fields.
- Previous by thread: Create Database in MS Access. & set properties of fields.
- Index(es):