Thread View: borland.public.cppbuilder.database.ado
1 messages
1 total messages
Started by crhras
Mon, 04 Sep 2006 15:38
fastest way to add many records in batch
Author: crhras
Date: Mon, 04 Sep 2006 15:38
Date: Mon, 04 Sep 2006 15:38
29 lines
1901 bytes
1901 bytes
I am adding 100,000 rows to an initialized MySQL database using the code
below. The application gets much slower as the number of records grows.
This is an obvious result of the database itself having more work to do with
indexes, etc. but is there also something that I can do on the application
side to speed things up ? I am wondering if the ClientDataSet, Provider,
etc. are also getting big and have more work to do. If so, what is the best
way to avoid this ?
Thank you.
Curt
I am using the following code to add the records:
ADOConnection1->Open();
DM->ClientDataSet1->Open();
for (int i = 0; i < equities; i++) {
for (int j = 0; j < days; j++) {
DM->ClientDataSet1->Insert();
... // table fields are loaded here
DM->ClientDataSet1->Post();
}
}
if (i%10 == 0) { // apply updates after 2000 rows are cached
DM->ClientDataSet1->ApplyUpdates(0);
}
}
DM->ClientDataSet1->ApplyUpdates(0);
DM->ADOConnection1->Close();
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads