Paul Tomblin <ptomblin@xcski.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