very, very slow query

Hello all:

Here's the deal. I have an app I made with VBA in Access 97. I recently wrote an import utility for admins to import new marketing data lists into the contact tables. Before doing this the list must be scrubbed against "do not call" and "do not mail" lists. The query I wrote for this is quite simple and ridiculously SLOW when importing large (20,000+) lists (DNC list is about 8,000 records). It goes like this:

docmd.runsql "UPDATE [newdata] set import_flag = 'IMPORT ERROR - DNC MATCH' WHERE phone IN (SELECT phone FROM [main_contact])"

works fine but incredibly slow. It took about 35 minutes to crunch a 20,000 record list.

How can I speed this up?
Would using recordsets be faster?

Any suggestions appreciated.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You might try:

docmd.runsql "UPDATE [newdata] SET import_flag = 'IMPORT ERROR - DNC MATCH' WHERE EXISTS (SELECT * FROM [main_contact] WHERE [newdata].phone = [main_contact].phone)"

This should be faster.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Change it to a join:

DoCmd.RunSQL "UPDATE [newdata] INNER JOIN [main_contact] ON [newdata].[phone] = [main_contact].[phone] SET [newdata].[import_flag] = 'IMPORT ERROR - DNC MATCH'"

The IN clause is very, very, very, very slow. Did I mention it was very slow ?
iloveunixAuthor Commented:
Ahh yes the EXISTS keyword. Completely forgot about that one. Works great now. Thanks so much.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

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.