Jump to content

is mysql_free_result worth it?


onedumbcoder

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.