[Dbix-class] Turning off prepared statements for LIKE searches

Toby Corkindale toby.corkindale at strategicdata.com.au
Fri Aug 21 05:03:53 GMT 2009


Jacob Bunk Nielsen wrote:
> Hi
> 
> I have read an interesting blog post about how prepared statements in
> PostgreSQL does not work well with LIKE searches. It can be found at:
> http://blog.endpoint.com/2009/08/debugging-prepared-statements.html
> 
> I'm hit by this in several places in my code. I have an example where I
> can go from ~290 ms to 0.5 ms for a single query, so quite a significant
> improvement, that I'd like to benefit from.
> 
> Of course I'm using DBIx::Class, so my question is how do I turn off
> prepared statements for LIKE searches?
> 
> I think I'd like to be able to turn off prepared statements everywhere I
> use LIKE. If that is not what I want, please tell me why :-)
> 
> Can anyone give my a clue as to how I would go about not using prepared
> statements for LIKE searches and still staying with DBIx::Class?

I believe you should just be able to pass the relevant connect options, ie:

my $dbh = DBI->connect(
	'dbi:Pg:dbname=myDatabase', $user, $passwd,
	{ pg_server_prepare => 0 }
);



More information about the DBIx-Class mailing list