Menu

#61 speed some prepared queries

open
API (4)
8
2013-01-16
2009-03-12
Reece Hart
No

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.

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.