Performance of UNION vs IN

From: Jean-Max Reymond <jmreymond(at)free(dot)fr>
To: pgsql-performance(at)postgresql(dot)org
Subject: Performance of UNION vs IN
Date: 2014-03-20 16:57:41
Message-ID: 532B1E05.70409@free.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

I have a very complex view zinfoexp and running the view as:
SELECT * FROM zinfoexp WHERE idmembre in (1,84)
take 2700 ms

So, I try another syntax:
SELECT * FROM zinfoexp WHERE idmembre = 1
union
SELECT * FROM zinfoexp WHERE idmembre = 84

and for me, two calls to my view takes a lot of time (may be x2) and it
takes 134 ms !

How is it possible that the optimizer cannot optimize the IN as UNION ?
I have a database postgresql 9.3 freshly vacuumed

--
Jean-Max Reymond
CKR Solutions Open Source http://www.ckr-solutions.com

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2014-03-20 17:08:50 Re: Getting query plan alternatives from query planner?
Previous Message Stefan Keller 2014-03-20 16:53:58 Getting query plan alternatives from query planner?