|
Question : Quickly add records to large database
|
|
Hello, I have written a program that must log records to a database every three seconds (44 fields of numeric data). Sometimes we must log for days on end, sometimes just a few hours here and there. We want to keep a few months of history as we go. As time goes on and the record count adds up, the process of adding a record takes longer and longer causing general program instability. It seems there are definitely some issues to consider when trying to add a record to a table containing hundreds of thousands of records. At some point I suppose the table must be archived and a new one started but I’m not sure where the practical limit is.
Being an old timer, I am using DAO. I’ve had issues in the past when dimming global recordsets so what I do is set the recordset in the procedure every time with an SQL statement (Select * FROM…), use the AddNew method then update and close. This process was taking 12 seconds, which of course blows the whole point of logging every three seconds so I started over with a blank table and now the process completes in the blink of an eye again.
Does anyone have any suggestions (other than a new table) for adding records and avoiding this slowdown?
|
|
Answer : Quickly add records to large database
|
|
1) Billystyx has a great idea...try it 2) Change your recordset SQL to something like this: SELECT * FROM MyTable WHERE 1=0 This will allow you full access to the table structure for the purpose of your recordset, but will return no records. Should be much quicker. 3) Use a dynamic INSERT with CurrentDB.Execute instead of generating a recordset. Much quicker results all around.
|
|
|
|