Re: sunquery and estimated rows - Mailing list pgsql-performance

From Tom Lane
Subject Re: sunquery and estimated rows
Date
Msg-id 3802.1082159101@sss.pgh.pa.us
Whole thread Raw
In response to sunquery and estimated rows  (Litao Wu <litaowu@yahoo.com>)
Responses Re: sunquery and estimated rows
List pgsql-performance
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

pgsql-performance by date:

Previous
From: Greg Stark
Date:
Subject: Re: Poor performance of group by query
Next
From: Christopher Browne
Date:
Subject: Re: Long running queries degrade performance