Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txijx-00071G-LZ for pgsql-performance@arkaria.postgresql.org; Tue, 22 Jan 2013 18:38:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Txijx-0006pn-3j for pgsql-performance@arkaria.postgresql.org; Tue, 22 Jan 2013 18:38:33 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txijv-0006op-Q9 for pgsql-performance@postgresql.org; Tue, 22 Jan 2013 18:38:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Txiju-0001YF-LL for pgsql-performance@postgresql.org; Tue, 22 Jan 2013 18:38:31 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.5/8.14.5) with ESMTP id r0MIcTgo024019; Tue, 22 Jan 2013 13:38:29 -0500 (EST) From: Tom Lane To: Andrew Dunstan cc: rudi , pgsql-performance@postgresql.org Subject: Re: High CPU usage after partitioning In-reply-to: <50FEA640.10201@dunslane.net> References: <50FDE039.3030601@dunslane.net> <50FEA640.10201@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Tue, 22 Jan 2013 09:46:24 -0500" Date: Tue, 22 Jan 2013 13:38:28 -0500 Message-ID: <24018.1358879908@sss.pgh.pa.us> 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 Andrew Dunstan writes: > On 01/22/2013 09:21 AM, rudi wrote: >> 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). This isn't about constraint exclusion I think. The main problem is in the sub-select: 9.0 isn't able to index-optimize a MAX() across a partitioned table, for lack of MergeAppend, so you end up scanning lots of rows there. 9.1 or 9.2 should be better. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance