From: | Doug McNaught <doug(at)wireboard(dot)com> |
---|---|
To: | Paul Tomblin <ptomblin(at)xcski(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: General question about DBI/DBD |
Date: | 2001-11-09 16:42:56 |
Message-ID: | m3pu6ruc8f.fsf@belphigor.mcnaught.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Paul Tomblin <ptomblin(at)xcski(dot)com> writes:
[converting Pg.pm to DBD::Pg]
> Also, the big program does a whole bunch of
> $conn->exec("SELECT * FROM tablename WHERE indexed_column = '$key'");
> and things like that. Is there a way in DBD:Pg I can re-parse those
> queries with "...indexed_column = :1" and then supply a different key each
> time? I remember when I used to write C programs that accessed Oracle
> (about 8 years ago, so the details are hazy), that was a major performance
> improvement.
You can basically do:
$stmt = $dbh->prepare("SELECT * FROM tablename WHERE indexed_column = ?");
$stmt->execute($key1);
$stmt->execute($key2);
This is nice because it will do any escaping in $key that needs to be
done.
However, PG doesn't cache query plans in this situation (unlike
Oracle) so you won't see a big performance win.
(Apologies if my syntax is off; I mostly use Java now.)
-Doug
--
Let us cross over the river, and rest under the shade of the trees.
--T. J. Jackson, 1863
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2001-11-09 17:06:44 | Re: PSQL anc compile errors |
Previous Message | Stephan Szabo | 2001-11-09 16:23:24 | Re: Precision problems with float8 |