FindFirst vs. Query->OpenRecordset

I have a database that gets updates in the form of a raw text file. The program reads in the first line, parses the data into correct array, then calls the update sub. The update sub looks at the first record, "PrimaryKey", and opens a recordset based on "Where PK= " & arr(0)'PrimaryKey
If nothing is returned, it is assumed this is a new record, and adds it. If a record is returned it is the edited. The code for this is simple, but very slow!!  I am using DBJet btw.  Would it make since to open the recordset as a whole and do a findfirst?  Originally when I wrote this, I was opening the table using the dbOpenTable option, and using a seek. Very fast, but I plan on upsizing someday to SQL, so I must use code structure that will allow this upsize.  That is at least 2 years from now, though, and I need to optimize speed for dbJet.  Thanks.

Info: approxx 145,000 records with 19 fields are updated every day.  Using DAO v2.0, VB6.
Who is Participating?
watyConnect With a Mentor Commented:
If you can isolate the update and new records, you can improve the adding/update in the database.

I have posted this as answer as you told you liked my answer.
I had to do something like that in a project with MS SQL.
I do as follow :

  I update each row by default.
  If no error was produced, the update was good.
  If an error was produced, I insert the row.

  I made the update and insert using SQL statment
     Update ... Where
     Insert into ...

This was the fastest way. When you will upgrade to SQL Server, you add dbSQLPassThrough to your execute.

If you still want to use your way. You should not use FindFirst wich is not optimized
Just a question...

Is your app normally doing more inserts or updates?
Or it about half and half?

Waty proposed a VERY good solution for you if you have mostly updates!
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Don't worry too much about your up-size anyway.

In two years Microsoft will have probably started to get away from JET/DAO and will be forcing us into UDA/OLEDB/ADO...
redbaron082997Author Commented:
Actually the app is a 50/50 split at times.  Our stores are sending information about their inventory.  During a normal week, it will be a file showing all inventory that has a changed stock status.  But during promotions, a bunch of sku's are created and must be added.  

I am pretty sure that I can isolate the two events by running a procedure that creates a temp file of just the changes, then another of additions. Would this be much faster, or would the use of an error condition triggering the events sufice?

WATY- I do like your "answer". Thanks.
If you can identify from the import file what is "new" and what is update, I would rip the import file into two files...

Then when you start posting to Access you will only have one database transaction to worry with... And it will either succeed or fail, there will no over-head with testing to see if it is there or not.

If you can't do that, then you are probably about as good as you are going to get with Access...
redbaron082997Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.