ASP 101 - Active Server Pages 101 - Web05
The Place ASP Developers Go!

Please visit our partners

Windows Technology Windows Technology
15 Seconds
ASP 101
ASP Wire
VB Forums
VB Wire
internet.commerce internet.commerce
Partners & Affiliates

ASP 101 is an site
ASP 101 is an site
Internet News
Small Business
Personal Technology

Corporate Info
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash

 Top ASP 101 Stories Top ASP 101 Stories
Getting Scripts to Run on a Schedule
The Top 10 ASP Links @
What is and Why Do I Need It?

Name Your Development Sites
Show All Tips >>
ASP 101 RSS Feed ASP 101 Updates

Quick Tips

Use variables to speed up collection access
Whenever you access a collection such as Request.ServerVariables or Request.Form, the script processor needs to go into the collection to look up the value of the item you request. While this doesn't seem like it takes a long time, it's actually relatively slow when compared to accessing local variables.

If you find yourself using the same item from a collection more than a couple times, declare a local variable and assign the value of the item in the collection to it the first time you need to access it. From then on you can use the local variable to retrieve the value to prevent the computer from needing to access the collection again.

The same thing goes for things like the field object of a recordset. Using a local variable saves the collection lookup time and while it may seem trivial, think about some of the loops that you're doing it inside of. A little bit of inefficiency adds up all of a sudden when you consider the number of times you're doing it!

You won't notice a huge speed increase. In fact, you probably won't even be able to tell the difference, but on a high traffic site the small amount of time saved each time the page is run can really add up.
Previous      Show All Tips      Next

If you have a tip you would like to submit, please send it to:

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback
The Network for Technology Professionals



Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers