speed some prepared queries
Status: Beta
Brought to you by:
reece
Prepared queries *that contain params* cannot be optimized and the plan usually (always?) uses seq scan. This led to poor performance in get_pseq_id_from_alias_regexp, and probably elsewhere.
It turns out that DBD::Pg provides a way to turn off server side preparation as needed for individual statements, such as:
my $sql = "SELECT DISTINCT pseq_id FROM palias WHERE lower(alias) ~ lower(?)";
my $sth = $u->prepare( $sql );
$sth->{pg_server_prepare} = 0;
This is much faster than without the p_s_p default (1).
See DBD::Pg and http://archives.postgresql.org//pgsql-performance/2008-07/msg00194.php .
The goal of this ticket is to review all prepared queries for cases that might be improved by pg_server_prepare = 0.