Re: Weird performance drop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> From: pgsql-performance-owner@xxxxxxxxxxxxxx 
> [mailto:pgsql-performance-owner@xxxxxxxxxxxxxx] 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



[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux