Re: Wacky query plan, why?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Maksim Likharev <mlikharev(at)aurigin(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Wacky query plan, why?
Date: 2003-07-25 23:12:09
Message-ID: 20030725160904.K44288-100000@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;
?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maksim Likharev 2003-07-25 23:26:20 Re: Wacky query plan, why?
Previous Message Maksim Likharev 2003-07-25 22:28:44 Wacky query plan, why?