Re: A query become very slow after upgrade from 8.1.10 to 8.4.5

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Yaocl <chunlinyao(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: A query become very slow after upgrade from 8.1.10 to 8.4.5
Date: 2010-11-02 22:30:08
Message-ID: 17301.1288737008@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Yaocl <chunlinyao(at)gmail(dot)com> writes:
> SELECT t_a.id FROM t_a
> WHERE EXISTS ( SELECT t_b.id FROM t_b, t_c
> WHERE t_b.id = t_a.id AND t_c.flag = 'f')

I have some hopes for fixing this in 9.1, but nothing is going to happen
in 8.4 or 9.0. In the meantime, is it intentional that there is no join
clause between t_b and t_c? That'd be a lot more efficient as two
separate EXISTS tests, ie

WHERE EXISTS ( SELECT 1 FROM t_b WHERE t_b.id = t_a.id ) AND
EXISTS ( SELECT 1 FROM t_c WHERE t_c.flag = 'f')

but I wonder whether this query doesn't simply reflect a logic error on
the client side.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Conor Walsh 2010-11-02 22:40:32 Re: Array interface
Previous Message Jon Nelson 2010-11-02 22:17:00 Re: [PERFORM] typoed column name, but postgres didn't grump