Re: Query runs forever after upgrading to 9.3

From: Christoph Berg <christoph(dot)berg(at)credativ(dot)de>
To: Andrus <kobruleht2(at)hot(dot)ee>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Query runs forever after upgrading to 9.3
Date: 2013-09-23 13:46:34
Message-ID: 20130923134634.GB2062@msgid.df7cb.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Re: Andrus 2013-09-23 <E04C65FDEE80430DB6499621E2EC36BC(at)dell2>
> SELECT * FROM toode
> WHERE toode in (SELECT toode FROM tempkaive)
> OR toode in (SELECT toode FROM tempalgsemu)

Generally, WHERE IN (SELECT) should be rewritten as WHERE EXISTS
(SELECT):

SELECT * FROM toode o
WHERE EXISTS (SELECT toode FROM tempkaive i WHERE o.toode = i.toode)
OR EXISTS (SELECT toode FROM tempalgsemu i WHERE o.toode = i.toode)

Also, ANALYZEing the tables after the upgrade might help if this has
not yet been done.

Christoph
--
cb(at)df7cb(dot)de | http://www.df7cb.de/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jayadevan M 2013-09-23 13:58:40 Re: Query runs forever after upgrading to 9.3
Previous Message Andrus 2013-09-23 13:38:25 Query runs forever after upgrading to 9.3