Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>When a request is served php "cleans" the instance and frees resources and other variables. This is done in several steps. Since fastcgi keeps the process alive after a request not all steps are executed and not all memory is freed. There is e.g. EG(persistent_list) which is used by <a href="http://docs.php.net/mysql_pconnect" rel="noreferrer">mysql_pconnect()</a>, <a href="http://docs.php.net/pg_pconnect" rel="noreferrer">pg_pconnect()</a>, ... This list isn't emptied between requests as long as the process keeps alive (could be, depending on the actual implementation, but that would defy the purpose of EG(persistent_list)). If you use persistent connections your script might get a "re-used" connection established during a previous request.<br> To (re-)use a prepared statement directly you need the identifier for that statement (and that connection). When using (php-)postgresql this is simply a (connection-wise) unique string you pass to <a href="http://docs.php.net/pg_execute" rel="noreferrer">pg_execute()</a>, so your script has no problem to gain access to the statement previously prepared by another instance (using the same connection).<br> Using <a href="http://docs.php.net/mysqli" rel="noreferrer">mysqli</a> or <a href="http://docs.php.net/pdo" rel="noreferrer">PDO-mysql</a> you need a resource/object as statement identifier. That's kind of a problem since neither the mysqli nor the pdo extension seem to offer a way of storing the resource in EG(persist_list) between requests and you can't recreate it either. Unless php-fpm offers such a "service" it's seems impossible to re-use a mysql prepared statement directly.<br> All you can hope for is MySQL's <a href="http://dev.mysql.com/doc/refman/5.1/en/query-cache-operation.html" rel="noreferrer">server-side query cache</a>. In recent versions (see link) it may recognize the statement when using prepared statements. But even then it doesn't re-use the actual prepared statement:</p> <blockquote>For a prepared statement executed via the binary protocol, comparison with statements in the query cache <i>is based on the text of the statement after expansion of ? parameter markers</i>. The statement is compared only with other cached statements that were executed via the binary protocol. That is, for query cache purposes, statements issued via the binary protocol are distinct from statements issued via the text protocol. </blockquote> <p>So, if I'm not mistaken, currently you can't re-use a mysql statement prepared during a previous request in php.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload