Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2005, 11:34 AM
Authorized User
 
Join Date: Jul 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Find in Loop too slow

Hello,
I am looking for a fast way to do the following:
Loop through a set of records ordered by the date they last logged on (LogOnDate). For each record in the loop I want to display the user’s city and state (which requires accessing a separate data base that associates zip codes with city and state).

The way I doing this currently is:
Do While Not oRSusers.EOF
…..
    oRSzipCodes.Find "ZIPCode = '" & oRSusers("ZipCode") & "'"
    Response.Write oRSzipCodes("City") & ", " & oRSzipCodes("State")
    oRSzipCodes.MoveFirst ‘THIS “RESETS” THE RS SO THE FIND WILL WORK ON THE NEXT LOOP AS FIND CAN ONLY SEARCH FORWARD
Loop

This works fine, but takes so long to execute (almost 1 second per record). I found I could speed it up greatly (so that 30 records displayed almost instantaneously) by ordering the records by ZipCode ASC and removing the “oRSzipCodes.MoveFirst”. This is great but I need to display the records by LogOnDate.

Any ideas how I can increase execution speed but still order the records properly?

Thanks, Mischa


 
Old July 7th, 2005, 05:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

What is the query that you use? Can you post that along with the table structures too. I hope a join would solve it for you. BTW, what is the database that you use in your case?

_________________________
- Vijay G
Strive for Perfection
 
Old July 8th, 2005, 08:42 AM
Authorized User
 
Join Date: Jul 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oRSusers.Open "SELECT UserID, Photo1, UserName, DOB, MySex, ZipCode, YourAge, YourSex, FriendSex, EmailSex, TravelSex, HeadLine, DescribeYourSelf FROM UserData ORDER BY UserID ASC", oConn, adLockReadOnly, adLockReadOnly, adCmdText

oRSzipCodes.Open "SELECT ZIPCode, City, State FROM ZIPCodes WHERE CityType = 'D' ORDER BY ZIPCode ASC" , "DSN=zipcodesdsn ", adLockReadOnly, adLockReadOnly, adCmdText

Not sure what your asking for the “table structures”….

Yea, I think a join may just do it. I’ll try that and let you know.

Thanks, Mischa


 
Old July 8th, 2005, 05:41 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes, you can use join to achieve that, thus avoid finding a match from within the loop for every record. That would be far better than your current approach.

I was asking about the schema of those tables in question, so that to better understand what you are trying to achieve, anyways no problem. The queries you posted were sufficient.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Word Doc from Access - find, find next save donaldmaloney Access VBA 1 May 25th, 2005 11:09 AM
Create a find and a find and replace in VB.NET snowy0 VB How-To 0 January 26th, 2004 07:03 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.