Re: Wacky query plan, why?

Поиск
Список
Период
Сортировка
От Maksim Likharev
Тема Re: Wacky query plan, why?
Дата
Msg-id 56510AAEF435D240958D1CE8C6B1770A016D2DD1@mailc03.aurigin.com
обсуждение исходный текст
Ответ на Wacky query plan, why?  ("Maksim Likharev" <mlikharev@aurigin.com>)
Ответы Re: Wacky query plan, why?  (Mike Mascari <mascarm@mascari.com>)
Re: Wacky query plan, why?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список pgsql-general
My be I too spoiled by MS SQL Server, but does'nt
syntax:

update prod.t_results set expdate=e.termdate from
     work.termdate e, prod.t_results r where e.docid=r.docid;
or
update prod.t_results set expdate=e.termdate from
     work.termdate e inner join prod.t_results r on e.docid=r.docid;

is standard SQL-92 update FROM form?
just trying to understand.


-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com]
Sent: Friday, July 25, 2003 4:12 PM
To: Maksim Likharev
Cc: pgsql-general
Subject: Re: [GENERAL] Wacky query plan, why?


On Fri, 25 Jul 2003, Maksim Likharev wrote:

> I have 2 queries, one is never returns, like explain shows
677195846.00
> cost
>     and another doing the same job works ( cost 6072.00 )
>
> I do not understand one thing, why query number one, generates so
> unbelievably
> screwed up plan?
>
> why it does not use index?
>
> query # 1:
>
------------------------------------------------------------------------
> ------
> explain update prod.t_results set expdate=e.termdate from
>     work.termdate e, prod.t_results r where e.docid=r.docid;

This is almost certainly not what you meant.  You haven't constrained
the update table (t_results) to the results of the from.  Adding
t_results
r to the from joins an additional copy of the table (it's not an alias
for
the update table).

Why not just
 update prod.tresults set expdate=e.termdate from work.termdate where
  e.docid=t_results.docid;
?


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

Предыдущее
От: Stephan Szabo
Дата:
Сообщение: Re: Wacky query plan, why?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Function index qeustion