From: Tom Lane <tgl@sss.pgh.pa.us>
To: kouber@saparev.com
Cc: pgsql-performance@postgresql.org
Subject: Re: LIMIT confuses the planner
Date: Mon, 23 Feb 2009 13:01:50 -0500
Message-ID: <18725.1235412110@sss.pgh.pa.us> (raw)
In-Reply-To: <49A2DFFA.8000001@saparev.com>
References: <49A295F0.5010405@saparev.com>
<49A2A450.20002@archonet.com>
<49A2DFFA.8000001@saparev.com>
Kouber Saparev <kouber@saparev.com> writes:
> Now the planner believes there're 910 rows, which is a bit closer to the
> real data:
> swing=# select avg(length) from (select username, count(*) as length
> from login_attempt group by username) as freq;
> avg
> ----------------------
> 491.6087310427555479
> (1 row)
Hmph, that's still not real good. Ideally it should be estimating
*less* than the average frequency, because the estimate is made after
excluding all the most-common-values, which evidently 'kouber' is not
one of. I suppose there's quite a large number of infrequently-seen
usernames and the ndistinct estimate is much less than reality? (Look
at the pg_stats row for this column.) It might be worth going all the
way to stats target 1000 for this column.
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, kouber@saparev.com
Subject: Re: LIMIT confuses the planner
In-Reply-To: <18725.1235412110@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