Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 532
  • Last Modified:

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.
Thanks
0
redbaron082997
Asked:
redbaron082997
  • 3
  • 2
  • 2
1 Solution
 
watyCommented:
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
 
0
 
mcixCommented:
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!
0
 
mcixCommented:
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...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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.
0
 
mcixCommented:
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...
0
 
watyCommented:
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.
0
 
redbaron082997Author Commented:
thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now