Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txf7b-0003xO-LP for pgsql-performance@arkaria.postgresql.org; Tue, 22 Jan 2013 14:46:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Txf7b-0007qQ-5c for pgsql-performance@arkaria.postgresql.org; Tue, 22 Jan 2013 14:46:43 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txf7Z-0007pT-Nm for pgsql-performance@postgresql.org; Tue, 22 Jan 2013 14:46:41 +0000 Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txf7X-0000oC-O2 for pgsql-performance@postgresql.org; Tue, 22 Jan 2013 14:46:41 +0000 X-Originating-IP: 217.70.178.147 Received: from mfilter19-d.gandi.net (mfilter19-d.gandi.net [217.70.178.147]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id D2FE4A80B6; Tue, 22 Jan 2013 15:46:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter19-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter19-d.gandi.net (mfilter19-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id Cazgd2G8T7B7; Tue, 22 Jan 2013 15:46:26 +0100 (CET) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id F2E66A80D3; Tue, 22 Jan 2013 15:46:25 +0100 (CET) Message-ID: <50FEA640.10201@dunslane.net> Date: Tue, 22 Jan 2013 09:46:24 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: rudi CC: pgsql-performance@postgresql.org Subject: Re: High CPU usage after partitioning References: <50FDE039.3030601@dunslane.net> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) 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 On 01/22/2013 09:21 AM, rudi wrote: > On Tue, Jan 22, 2013 at 3:04 PM, Merlin Moncure > wrote: > > let's see the query -- it's probably written in such a way so as to > not be able to be optimized through CE. > > > The query is pretty simple and standard, the behaviour (and the plan) > is totally different when it comes to a partitioned table. > > Partioned table query => explain analyze SELECT "sb_logs".* FROM > "sb_logs" WHERE (device_id = 901 AND date_taken = (SELECT > MAX(date_taken) FROM sb_logs WHERE device_id = 901)); > And there you have it. Constraint exclusion does not work in cases like this. It only works with static expressions (such as a literal date in this case). cheers andrew -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance