| From: | Denis Gasparin <denis(at)edistar(dot)com> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | Prepared queries vs Non-prepared |
| Date: | 2007-03-28 08:30:00 |
| Message-ID: | 460A2788.5010806@edistar.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi!
I am testing the PHP PDO library versus the old style PHP postgres
functions.
I noted that PDO library declare and prepare every statement. I mean:
$s = $db->query("select * from test where field=1");
is equivalent to
$s = $db->prepare("select * from test where field=?");
$s->execute(array('1'));
I logged the queries sent to the database and i saw that they are the
same (apart obviously the parameter):
PREPARE pdo_pgsql_stmt_b7a71234 AS select * from test where field=1
<BIND>
EXECUTE <unnamed> [PREPARE: select * from test where field=1]
PREPARE pdo_pgsql_stmt_b7a713b0 AS select * from test where field=$1
<BIND>
EXECUTE <unnamed> [PREPARE: select * from test where field=$1]
Speaking about postgresql performance...
would not it be more efficient executing directly the query in the first
case ($db->query) than
preparing a statement without parameters and then executing it?
Thank you in advance,
Denis
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dmitry Koterov | 2007-03-28 08:40:22 | Re: Strange behaviour under heavy load |
| Previous Message | Richard Huxton | 2007-03-28 07:44:45 | Re: tweaks for write-intensive dbs ? |