Jump to content

[SOLVED] mysql_query and arrays


Lethe

Recommended Posts

General question...

 

If you run a mysql select statement with a lot of records (lets say a 1000 records at most) that you will be reusing multiple times and looping through them recursively is it generally best practice to immediately put the results in an array and free the mysql results?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/151022-solved-mysql_query-and-arrays/
Share on other sites

If you put them all into an array imagine - one user accessing 1,000 records that array takes up memory of the web server. If let's say 100 people access it that's 100x1,000 times the amount of memory eaten up.

 

It may be freed at the end but I'd say best to read through the result without passing it to an array unless you need some of the data later on in the script.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.