Re: possible bug in 8.4

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: possible bug in 8.4
Дата
Msg-id 87y6ydl6m1.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на possible bug in 8.4  (Grzegorz Jaskiewicz <gj@pointblue.com.pl>)
Ответы Re: possible bug in 8.4  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Grzegorz Jaskiewicz <gj@pointblue.com.pl> writes:

> gj=# explain select a.a from a where a not in (select a from b);
>                                QUERY PLAN
> -------------------------------------------------------------------------
>  Seq Scan on a  (cost=99035.00..257874197565.00 rows=3000000 width=4)
>    Filter: (NOT (subplan))
>    SubPlan
>      ->  Materialize  (cost=99035.00..171493.00 rows=5400000 width=4)
>            ->  Seq Scan on b  (cost=0.00..75177.00 rows=5400000  width=4)
> (5 rows)
>
>
> that's absolutely humongous cost, and it really does take ages before  this
> thing finishes (had to kill it after an hour).

I think Postgres can't do better because there could be a NULL in the
subquery. If there's a NULL in the subquery then no record would match.

Now your column is NOT NULL so Postgres could do better but AFAIK we don't
look at column constraints like NOT NULL when planning. Historically we
couldn't because we didn't have plan invalidation -- and the plan you posted
below with the Anti-Join is brand new in 8.4 -- so there is room for
improvement but it's not exactly a bug.


--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's On-Demand Production
Tuning


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Updates of SE-PostgreSQL 8.4devel patches (r1324)
Следующее
От: Simon Riggs
Дата:
Сообщение: Re: Latest version of Hot Standby patch