From: Tom Lane <tgl@sss.pgh.pa.us>
To: Steinar H. Gunderson <sgunderson@bigfoot.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Planner having way wrong estimate for group aggregate
Date: Sat, 18 Sep 2004 15:48:13 -0400
Message-ID: <7261.1095536893@sss.pgh.pa.us> (raw)
In-Reply-To: <20040918170117.GA3354@uio.no>
References: <20040918170117.GA3354@uio.no>
"Steinar H. Gunderson" <sgunderson@bigfoot.com> writes:
> Now, my first notion was creating a functional index to help the planner:
> ...
> However, this obviously didn't help the planner (this came as a surprise to
> me, but probably won't come as a surprise to the more seasoned users here :-)
7.4 doesn't have any statistics on expression indexes. 8.0 will do what
you want though. (I just fixed an oversight that prevented it from
doing so...)
> Actually, it seems that the higher I set statistics on "tid", the worse the
> estimate becomes.
I believe that the estimate of number of groups will be exactly the same
as the estimate of the number of values of tid --- there's no knowledge
that date_trunc() might reduce the number of distinct values.
> Any ideas for speeding this up?
In 7.4, the only way I can see to force this to use a hash aggregate is
to temporarily set enable_sort false or raise sort_mem.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, sgunderson@bigfoot.com
Subject: Re: Planner having way wrong estimate for group aggregate
In-Reply-To: <7261.1095536893@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox