MySQL Forums
Forum List  »  PHP

Re: prepared statements for multiple queries
Posted by: Alexander Zorach
Date: March 27, 2009 11:16AM

I actually got the prepared statements working--the problem was that I wasn't calling free_result() after fetching the results before calling the next statement.

As you recommended, I called microtime and found that, using prepared statements, I actually had slower execution time AND with a separate test I found that my script was using more memory. The code was also substantially longer and less readable.

I guess I was misled by documentation on the internet that seems to give the impression that you gain a lot in performance if you use prepared statements to run the same query multiple times using a different parameter.

I think you are right that the proper way of dealing with this is to find a way to fetch all rows at once. I've already done that in the places in my site in which it is easy to do...maybe it's worth doing the more tricky cases next (i.e. some pages may have multiple tables, and some paragraphs, each of which need to perform some query to pull something in the middle of them...if I could somehow parse the page once, pull queries, and populate the proper text, it would solve the problem).

Options: ReplyQuote


Subject
Written By
Posted
Re: prepared statements for multiple queries
March 27, 2009 11:16AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.