From: Tom Lane <tgl@sss.pgh.pa.us>
To: Litao Wu <litaowu@yahoo.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: sunquery and estimated rows
Date: Fri, 16 Apr 2004 19:45:01 -0400
Message-ID: <3802.1082159101@sss.pgh.pa.us> (raw)
In-Reply-To: <20040416214529.10468.qmail@web13125.mail.yahoo.com>
References: <20040416214529.10468.qmail@web13125.mail.yahoo.com>
Litao Wu <litaowu@yahoo.com> writes:
> When I included a subquery, the estimated rows (1240)
> is way too high as shown in the following example.
> select * from test
> where scope=(select 10);
The planner sees that as "where scope = <some complicated expression>"
and falls back to a default estimate. It won't simplify a sub-select
to a constant. (Some people consider that a feature ;-).)
The estimate should still be derived from the statistics for the
scope column, but it will just depend on the number of distinct
values for the column and not on the specific comparison constant.
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, litaowu@yahoo.com
Subject: Re: sunquery and estimated rows
In-Reply-To: <3802.1082159101@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