Solved

FindFirst vs. Query->OpenRecordset

Posted on 1998-09-01
7
530 Views
Last Modified: 2012-06-27
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
Comment
Question by:redbaron082997
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1432277
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
 
LVL 4

Expert Comment

by:mcix
ID: 1432278
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
 
LVL 4

Expert Comment

by:mcix
ID: 1432279
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 1

Author Comment

by:redbaron082997
ID: 1432280
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
 
LVL 4

Expert Comment

by:mcix
ID: 1432281
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
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1432282
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
 
LVL 1

Author Comment

by:redbaron082997
ID: 1432283
thanks!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month6 days, 13 hours left to enroll

622 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question