Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQgHt-0000Lx-T4 for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2014 16:57:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WQgHt-0000XM-CS for pgsql-performance@arkaria.postgresql.org; Thu, 20 Mar 2014 16:57:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQgHs-0000WG-58 for pgsql-performance@postgresql.org; Thu, 20 Mar 2014 16:57:48 +0000 Received: from dedi.ckr-solutions.com ([195.154.211.35]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WQgHo-0007tY-5l for pgsql-performance@postgresql.org; Thu, 20 Mar 2014 16:57:47 +0000 Received: from localhost (localhost [127.0.0.1]) by dedi.ckr-solutions.com (Postfix) with ESMTP id 47CDC262D30 for ; Thu, 20 Mar 2014 17:57:43 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ckr-solutions.com Received: from dedi.ckr-solutions.com ([127.0.0.1]) by localhost (dedi.ckr-solutions.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7LvegUD6PpXi for ; Thu, 20 Mar 2014 17:57:41 +0100 (CET) Received: from [IPv6:2a01:e35:2f3a:2500:1593:358b:821d:2dfc] (unknown [IPv6:2a01:e35:2f3a:2500:1593:358b:821d:2dfc]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: jmreymond@ckr-solutions.com) by dedi.ckr-solutions.com (Postfix) with ESMTPSA id 53E6725ED24 for ; Thu, 20 Mar 2014 17:57:41 +0100 (CET) Message-ID: <532B1E05.70409@free.fr> Date: Thu, 20 Mar 2014 17:57:41 +0100 From: Jean-Max Reymond User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Performance of UNION vs IN Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org 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 -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance