Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

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.
0
iloveunix
Asked:
iloveunix
1 Solution
 
malekamCommented:
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.
0
 
shanesuebsahakarnCommented:
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 ?
0
 
iloveunixAuthor Commented:
Ahh yes the EXISTS keyword. Completely forgot about that one. Works great now. Thanks so much.
0

Featured Post

Industry Leaders: 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!

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