Re: Slow query with a lot of data

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Scott Carey" <scott(at)richrelevance(dot)com>
Cc: "Moritz Onken" <onken(at)houseofdesign(dot)de>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow query with a lot of data
Date: 2008-08-20 18:28:18
Message-ID: 3232.1219256898@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"Scott Carey" <scott(at)richrelevance(dot)com> writes:
> The planner actually thinks there will only be 28704 rows returned of width
> 12. But it chooses to sort 53 million rows before aggregating. Thats
> either a bug or there's something else wrong here. That is the wrong way
> to aggregate those results no matter how much work_mem you have unless I'm
> completely missing something...

That does look weird. What are the datatypes of the columns being
grouped by? Maybe they're not hashable?

Another forcing function that prevents use of HashAgg is DISTINCT
aggregates, but you don't seem to have any in this query...

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message André Volpato 2008-08-20 18:30:25 Postgres not using array
Previous Message Tom Lane 2008-08-20 18:18:33 Re: Optimizing a VIEW