When you process many records from a database, especially those cross-referenced with another database, try to modify the code
to eliminate -- or at least reduce -- duplicate requests for the
For example, you generate a detailed sales report from a
database that contains only product numbers and actual sales. In the
report you also need to display the corresponding product names
that are maintained in a different database.
You may be able to implement a basic caching mechanism
so the product names are only retrieved once for each product number.
This approach will consume more memory. But, depending
on your specific data set, it also can make a significant impact
on the total amount of time spent reading data.