Re: Slow query postgres 8.3

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

 



"Anne Rosset" <arosset@xxxxxxxxxx> wrote:
 
>                            ->  Index Scan using role_oper_obj_oper
> on role_operation  (cost=0.00..93.20 rows=45 width=9) (actual
> time=0.236..71.291 rows=6108 loops=1)
>                                  Index Cond:
> (((object_type_id)::text = 'SfMain.Project'::text) AND
> ((operation_category)::text = 'admin'::text) AND
> ((operation_name)::text = 'admin'::text))
 
This looks like another case where there is a correlation among
multiple values used for selection.  The optimizer assumes, for
example, that category = 'admin' will be true no more often for rows
with operation_name = 'admin' than for other values of
operation_name.  There has been much talk lately about how to make
it smarter about that, but right now there's no general solution,
and workarounds can be tricky.
 
In more recent versions you could probably work around this with a
Common Table Expression (CTE) (using a WITH clause).  In 8.3 the
best idea which comes immediately to mind is to select from the
role_operation table into a temporary table using whichever of those
three criteria is most selective, and then join that temporary table
into the rest of the query.  Maybe someone else can think of
something better.
 
-Kevin

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


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

  Powered by Linux