Re: Using max() MUCH slower in v7.1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Gordan Bobic" <gordan(at)freeuk(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Using max() MUCH slower in v7.1
Date: 2001-01-17 17:29:10
Message-ID: 17696.979752550@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Gordan Bobic" <gordan(at)freeuk(dot)com> writes:
> CREATE VIEW LastDate AS
> SELECT Company,
> max(Date) AS Date
> FROM PastInvoices
> GROUP BY Company;

> And then call it like
> SELECT Date FROM LastDate ORDER BY Date WHERE Company = 'SomeCompany';

> It takes ABSOLUTELY forever. The table has about 25-30M records.

The problem is that 7.1 isn't pushing the WHERE restriction down into
the view. Check the 'rows' estimate for the indexscan: is it showing
the whole table being returned, or just a few rows? It's probably
applying the WHERE restriction at the top, after computing the complete
output of the view :-(

I had a note to see if this could be improved before 7.1, but haven't
gotten to it yet. At the moment it's a price we paid for the more
flexible implementation of views in 7.1...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ligia M. Pimentel 2001-01-17 17:42:50 Re: View tables relationship
Previous Message Alfred Perlstein 2001-01-17 17:23:50 Re: MySQL file system