INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Query Runnin Slow

Query Runnin Slow

(OP)
I am running the following query to pull random records from a DBF file:

CODE

    conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & Path & ";Extended Properties=dBASE 5.0;User ID=;Password="
    With rs
       .CursorLocation = adUseServer
       .Open "SELECT TOP 50 * FROM [" & FileName & "] " & WhereByClause & _
       "ORDER BY RND([INPTRCRDNM])", conn, adOpenStatic, adLockReadOnly, adCmdText
       .Close
    End With

Any ideas on how to speed this up?  It is taking 2 minutes to return the recordset.  Thanks.

Swi

RE: Query Runnin Slow

(OP)
I should have mentioned that the DBF has about 800,000 records.

Swi

RE: Query Runnin Slow

Is there an index on the table?

"Artificial Intelligence is no match for Natural Stupidity"
 

RE: Query Runnin Slow

(OP)
No, and I can not be guaranteed that there will be.  Would it be better to take the time to create an index through code and then run the query?

Swi

RE: Query Runnin Slow

You should notice some improvement with an indexed table - try it & post back...

"Artificial Intelligence is no match for Natural Stupidity"
 

RE: Query Runnin Slow

...Would it be better to take the time to create an index through code and then run the query?

Very likely yes ... particularly for a table of that size. The fields that you want indexed are the ones in your WHERE clause which, unfortunately, appears only as a variable in your post.

RE: Query Runnin Slow

(OP)
I will give both of your tips a try and post back when I get a chance.  Thanks.

Swi

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close