Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WaRWo-0005kF-Pa for pgsql-performance@arkaria.postgresql.org; Wed, 16 Apr 2014 15:13:34 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WaRWo-0001YH-5S for pgsql-performance@arkaria.postgresql.org; Wed, 16 Apr 2014 15:13:34 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WaRWn-0001YB-B7 for pgsql-performance@postgresql.org; Wed, 16 Apr 2014 15:13:33 +0000 Received: from ns3099999.ip-37-59-8.eu ([37.59.8.46] helo=mail.linos.es) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WaRWk-0006KY-8r for pgsql-performance@postgresql.org; Wed, 16 Apr 2014 15:13:32 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.linos.es (Postfix) with ESMTP id 0836860807C7 for ; Wed, 16 Apr 2014 17:13:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at ns3099999.ip-37-59-8.eu Received: from mail.linos.es ([37.59.8.46]) by localhost (ns3099999.ip-37-59-8.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id enNxoXb3zhMQ for ; Wed, 16 Apr 2014 17:13:25 +0200 (CEST) Received: from [192.168.254.4] (9.Red-83-61-242.dynamicIP.rima-tde.net [83.61.242.9]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: info@linos.es) by mail.linos.es (Postfix) with ESMTPSA id 6286560807C2 for ; Wed, 16 Apr 2014 17:13:25 +0200 (CEST) Message-ID: <534E9E14.5000304@linos.es> Date: Wed, 16 Apr 2014 17:13:24 +0200 From: Linos User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: unneeded joins on view Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 0.8 (/) 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 Hello all, I am trying to simplify some of the queries I use with my database creating a big view of all the possible attributes my items can have, the view is rather large: http://pastebin.com/ScnJ8Hd3 I thought that Postgresql would optimize out joins on columns I don't ask for when I use the view but it doesn't, this query: SELECT referencia FROM articulo_view WHERE referencia = '09411000'; Have this query plan: http://explain.depesz.com/s/4lW0 Maybe I am surpassing some limit? I have tried changing from_collapse_limit and join_collapse_limit but still the planner join the unneeded tables. Is possible to tell Postgresql do the right thing? If so, how? Thanks! Regards, Miguel Angel. -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance