From: Dave Dutcher <dave@tridecap.com>
To: 'Vincenzo Romano' <vincenzo.romano@gmail.com>
To: pgsql-performance@postgresql.org
Subject: Re: Weird performance drop
Date: Thu, 29 Mar 2007 18:12:58 -0500
Message-ID: <018c01c77257$cb0bd520$2e00a8c0@tridecap.com> (raw)
In-Reply-To: <200703292056.08459.Vincenzo.Romano@gmail.com>
> From: pgsql-performance-owner@postgresql.org
> [mailto:pgsql-performance-owner@postgresql.org] On Behalf Of
> Vincenzo Romano
>
> I thought that the query planner usually did a bad job on
> function bodies
> because they'd appear opaque to it.
> In this case it seems to me that the body is opaque only if I
> use the "like"
> operator.
If you run explain on a query that looks like "select * from a_table where
a_column like 'foo%'" (and you have the appropriate index) you will see that
postgres rewrites the where clause as "a_column >= 'foo' and a_column <
'fop'". I think your problem is that the query is planned when the function
is created, and at that time postgres doesn't know the value you are
comparing against when you use the like operator, so postgres can't rewrite
the query using >= and <. The problem doesn't happen for plain equality
because postgres doesn't need to know anything about what you are comparing
against in order to use equality.
Somebody else can correct me if I'm wrong.
Dave
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: dave@tridecap.com, vincenzo.romano@gmail.com
Subject: Re: Weird performance drop
In-Reply-To: <018c01c77257$cb0bd520$2e00a8c0@tridecap.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox