Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts

    mysql_free_result(), is it needed here?

    ok, im writing a big script for my own site and also for someone else's site, and im trying to make it as fast as possible. It has a template system, and currently uses 19 database tables. Its basically a CMS system, but with a few extra things specific to our sites.

    ok, so i need speed. Its currently 600 lines and im about 10% done in terms of functionality. Im averaging about 5 queries per page, some more, some less.

    Everything is split into functions, within a class. When i query, it is always within a function. what i want to know is, do i need to use mysql_free_result() to clear the query data (which would speed it up a bit) within the function, or is the data lost at the end of the function?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I wouldn't count too much on mysql_free_result() to bring great speed improvement, if you're not pulling out absurd quantities of data from your database. If I understood you correctly, you described the generation of one standard page in that CMS - correct? If so, I wouldn't worry about the 5 queries. It won't affect you negatively, though. Just make sure you don't free the result sets too soon.

    If you think that your app is going too slow, then better benchmark it with PEAR::Benchmark or the sample code on the manual page for microtime(). Once you know exactly at what point of execution the app slows down, you can concentrate on fine-tuning it where the need actually is. Maybe the connection to the database is more time-consuming, who knows? Get some hard numbers and let them say where and what to optimize.
    De gustibus non est disputandum.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    frankfurt, german banana republic
    Posts
    1,848
    Thanks
    0
    Thanked 0 Times in 0 Posts
    And regarding your last question: The memory allocated for the result sets will be freed upon the end of the script, not the end of the function using it.
    De gustibus non est disputandum.

  • #4
    Senior Coder missing-score's Avatar
    Join Date
    Jan 2003
    Location
    UK
    Posts
    2,194
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks for the advice mordred.

    The cms is running quite smoothly on my local server, i have a 256MB ram and the templates are being parsed for about 50 sections and data loaded in 50 milliseconds (depending what page). Im quite pleased with that.

    What i was also thinking about, is the administration where mass lists and data may need to be loaded for certain tasks. not just to speed up the script, but not abuse the server .

    thanks for your advice, i will get some better figures and decide whats best.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •