Re: BUG #5652: Optimizer does wrong thing with partitioned tables

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Chris Travers <chris(at)metatrontech(dot)com>
Cc: Euler Taveira de Oliveira <euler(at)timbira(dot)com>, Mladen Gogala <mladen(dot)gogala(at)vmsinfo(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5652: Optimizer does wrong thing with partitioned tables
Date: 2010-09-10 19:09:10
Message-ID: 1284145750.21846.7.camel@jdavis-ux.asterdata.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Fri, 2010-09-10 at 08:10 -0700, Chris Travers wrote:
> Just adding my voice to the "fix it" camp. Is there any reason the
> table scans in this sort of thing cannot be independently planned?

I don't think it's about independent planning. For instance, AVG clearly
can't be planned this way, there are particular properties of MAX that
allow the optimization:

1. MAX(x) can be rewritten as: ORDER BY x DESC LIMIT 1
2. The MAX of set S is the MAX of the MAXes of each partition of S

The optimizer knows about the former, but not the latter.

Regards,
Jeff Davis

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Mladen Gogala 2010-09-10 20:53:53 Re: BUG #5652: Optimizer does wrong thing with partitioned tables
Previous Message Jeff Davis 2010-09-10 19:00:20 Re: BUG #5652: Optimizer does wrong thing with partitioned tables