473,756 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PDOStatement::p repare overhead

With the move over to PHP 5.x I' mnow writing a lot of code that makes
use of prepared statements as the PHP manual has nothing but good
things to say about them. They have less overhead for the database,
they eliminate the possibility of SQL injection attacks, they are made
of sunshine and fluffy kittens, etc.

Then I got to thinking, in my methods I am preparing a statement and
then running it one to n times, depending on the method and what its
doing. But of course when you go out of scope in a method you destroy
the PDOStatement that you prepared. Of course it gets recreated when
you next run the function, but then what happens whtn the prepare()
statement is run again?

I'm working with Postgres so I assume the PDO driver is using the
prepared statement support already built into Postgres as opposed to
the PDO emulation layer. So what I want to know is what happens when
you prepare the same statement more than once, with different
PDOStatement objects? Will the entire query preparation process run
again or does the prepared statement get cached server side? From the
point of view of program logic it makes very little difference whether
or not the statement is prepared over from scratch, but I would
imagine that there is a performance price to be paid that would
totally negate the performance advantage of prepared statements for
queries that are only run once.

The reason I am asking this is to determine whether or not it is worth
the effort to modify my database querying classes so they store all
prepared statements in static variables? Doing so would allow me to
initialize each prepared statement as needed and only do it once per
page view, but it would require a fair amount of rewriting, a day or 2
at least. I'm wondering if the performance benefit would be enough to
justify the work involved.

Any comments you guys have would be appreciated.
Jan 2 '08 #1
0 1295

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2435
by: John Cecere | last post by:
I've run into this bug: http://bugs.php.net/bug.php?id=29902 I'm beside myself trying to get around this. My application is dying after processing 20 transactions because there is no way to close the connection. I've tried downloading and building the latest 5.1 CVS source via cvs -d :pserver:cvsread@cvs.php.net:/repository checkout -r PHP_5_1 php-src But this didn't help. The oci_close still always fails.
2
2515
by: James | last post by:
Hey everyone... I'm having an issue with a seemingly simple piece of PHP/MySQL I have a stored procedure in MySQL5 as such: SQL: -------------- DELIMITER $$; DROP PROCEDURE IF EXISTS `test`.`sp_returns_string`$$ CREATE PROCEDURE `test`.`sp_returns_string`(OUT vOutput varchar(32))
3
3454
by: DavidPL | last post by:
Hello, I have some problem with bind method in PDO on Oracle with clob | long column type. I have table named TEST_TABLE where I have two columns: ID (int 10, 0) and TEXT (varchar 4000 or long or clob). When I try execute PHP code (based on example in manual): <?php
5
16504
by: loudwinston | last post by:
Hello, I'm encountering a strange error with PDO. The server is FreeBSD 4.4, PHP 5.1.2, mySQL 4.0.20 with 4.1.18 client libs. I have the following code (usernames and passwords changed to protected the innocent ^_^) <? $db_dsn = "mysql:host=dbHost;dbname=dbName";
6
8133
by: Tonio | last post by:
Hello, I got and an exception handler, and I want, for each PDOException throwned, to get the whole query which didn't works. Is there a way to do this ? Thanks, Tonio
3
2463
by: Gilles Ganault | last post by:
Hi APC doesn't like it when I store the output of a SELECT: === include("apc.php"); $dbh = new PDO("sqlite:./test.sqlite"); $sql = "CREATE TABLE IF NOT EXISTS mytable (name TEXT)";
6
9663
by: Gordon | last post by:
I want to search a folder structure represented in a database. I'm using the ID and Parent columns model, and would like to be able to search a folder's subfolders as well as teh folder itself. To do this I'm getting a list of all the subfolders with a recursive function and building them into a CSV list of IDs. Example output: 472,944,925,931,938,1692,1005,1036,1046,1051,1042,1816,1819,921 I then want to do a select against the list...
2
1301
Dormilich
by: Dormilich | last post by:
Hi, currently I'm stuck on finding the error of one of my functions. I try to read data out of MySQL using PDO. the SQL string is loaded as Prepared Statement (PDO->prepare()) and shall be executed using PDOStatement->execute(). I already know: - there's no PDOException thrown - there's no Error message - the execute method returns false - the parameters are correctly passed (- all fields exist in the DB, they are either string types...
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9869
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8709
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.