We discuss PHP and cursors in these two threads:
PHP/PostgreSQL at the moment does not support parameterized queries such as with PHP/Oracle, where you "bind" a PHP variable to a parameter of a pre-compiled query. I hope that we will eventually get this ability, because it can have performance benefits in certain situations.
So a "parameterized query" really just means the query is pre-compiled in the database and only takes certain parameters, which are said to be "bound" to the query. It is not necessarily the same thing as a query that manipulates cursors to store temporary result sets.
But, if you use the cursor method I describe in the threads above, combined with a PL/pgSQL function, you can get some performance improvements. You might want to look at http://www.postgresql.org/idocs/ind...ql-cursors.html
, and pay attention to the section about bound cursor variables. The point here is that the query plan is cached (maintained in a compiled state), which gives you the same performance advantages of a parameterized query.
The real point of all of this, to sum it up, is "push as much intelligence as you can into the database". If you need to do something that involves several queries, but only requires a couple incoming variables, then creating a stored procedure to handle all these queries will save a lot
on I/O, since PHP doesn't have to talk back and forth to the database as much. (this is especially important if you are connecting to a database via network on another server).