onedumbcoder Posted July 29, 2009 Share Posted July 29, 2009 I am wondering if it is necessary or worth it to use mysql_free_result()? Quote Link to comment https://forums.phpfreaks.com/topic/167892-is-mysql_free_result-worth-it/ Share on other sites More sharing options...
BLaZuRE Posted July 29, 2009 Share Posted July 29, 2009 I am wondering if it is necessary or worth it to use mysql_free_result()? No, it's neither necessary nor worth it for the casual database user. MySQL automatically frees the memory at the end of the script. It's only necessary when you're running large queries, such as those often found in corporate environments. It certain cases, it can actually make you use more memory when using it inefficiently. Quote Link to comment https://forums.phpfreaks.com/topic/167892-is-mysql_free_result-worth-it/#findComment-885545 Share on other sites More sharing options...
onedumbcoder Posted July 29, 2009 Author Share Posted July 29, 2009 Thanks for the reply, but when you say "corporate environments" what does that mean? I have queries that are 40-50 lines grabbing from 6-7 tables, does that count as a large query? Quote Link to comment https://forums.phpfreaks.com/topic/167892-is-mysql_free_result-worth-it/#findComment-885549 Share on other sites More sharing options...
BLaZuRE Posted July 29, 2009 Share Posted July 29, 2009 Thanks for the reply, but when you say "corporate environments" what does that mean? I have queries that are 40-50 lines grabbing from 6-7 tables, does that count as a large query? When I say "corporate environments", I mean stuff like banks, non-profit organizations, stores, etc. that facilitate numerous, complex queries to large databases. I'd say you don't need to use it, but it largely depends on the server, your code efficiency, your database efficiency (are you using char(100) for an address, which usually only needs about 20 characters and is better as a varchar instead?), the number of connections you have open at a time (one, dozens, hundreds?), etc. It's not an exact science. I can't tell you, just because you have 1,000 queries you have to clear it every 397.3 queries. You can look at your "Runtime information" inside PHPMyAdmin to get a feel of how much memory you're using. I hope you mean that you have 40-50 lines of queries rather than each query is 40-50 lines. Quote Link to comment https://forums.phpfreaks.com/topic/167892-is-mysql_free_result-worth-it/#findComment-885565 Share on other sites More sharing options...
onedumbcoder Posted July 29, 2009 Author Share Posted July 29, 2009 thanks. and yes i have queries that are 40-50 lines each. Quote Link to comment https://forums.phpfreaks.com/topic/167892-is-mysql_free_result-worth-it/#findComment-885599 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.