Re: sunquery and estimated rows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Litao Wu <litaowu(at)yahoo(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: sunquery and estimated rows
Date: 2004-04-16 23:45:01
Message-ID: 3802.1082159101@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Litao Wu <litaowu(at)yahoo(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Christopher Browne 2004-04-17 11:59:23 Re: Long running queries degrade performance
Previous Message Greg Stark 2004-04-16 22:57:51 Re: Poor performance of group by query