Solved

FindFirst vs. Query->OpenRecordset

Posted on 1998-09-01
7
528 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
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!

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Access - Capture pressed key onclick 4 43
Help me. 3 69
Zip Folders Using Chilkat Routines 1 73
VB6 calling COM DLL written in Visual Studio 2003 6 10
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

756 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