Re: slow plan for min/max - Mailing list pgsql-performance

From Bruno Wolff III
Subject Re: slow plan for min/max
Date
Msg-id 20030909184954.GA14198@wolff.to
Whole thread Raw
In response to Re: slow plan for min/max  (Greg Stark <gsstark@mit.edu>)
List pgsql-performance
On Tue, Sep 09, 2003 at 12:54:04 -0400,
  Greg Stark <gsstark@mit.edu> wrote:
>
> So what would it take to implement this for "all" aggregates? Where I think
> "all" really just means min(), max(), first(), last().

There can be other aggregates where indexes are helpful. The case of interest
is when functions such that if the new item is contains the current value
of the aggregate then the new value of the aggregate with be that of the
current item. This allows you to skip looking at all of the other items
contained in the current item. Dual problems can also benefit in a similar
manner. In a case where the set is totally ordered by the contains index
(as is the case or max and min) then the problem is even simpler and you
can use the greatest or least element as appropiate.

pgsql-performance by date:

Previous
From: Josh Berkus
Date:
Subject: Re: slow plan for min/max
Next
From: Thomas Swan
Date:
Subject: Re: slow plan for min/max