On Sat, Feb 01, 2003 at 15:21:24 -0500, Greg Stark <[EMAIL PROTECTED]> wrote: > Tom Lane <[EMAIL PROTECTED]> writes: > > That just means you need some way for aggregates to declare which records they > need. The only values that seem like they would be useful would be "first > record" "last record" and "all records". Possibly something like "all-nonnull > records" for things like count(), but that might be harder.
I don't see how this is going to be all that useful for aggregates in general. min and max are special and it is unlikely that you are going to get much speed up for general aggregate functions. For the case where you really only need to scan a part of the data (say skipping nulls when nearly all of the entries are null), a DBA can add an appropiate partial index and where clause. This will probably happen infrequently enough that adding special checks for this aren't going to pay off. For min and max, it seems to me that putting special code to detect these functions and replace them with equivalent subselects in the case where an index exists (since a sort is worse than a linear scan) is a possible long term solution to make porting easier. In the short term education is the answer. At least the documentation of the min and max functions and the FAQ, and the section with performance tips should recommend the alternative form if there is an appropiate index. ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org