Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id A7BDD1337B56 for ; Sat, 4 Dec 2010 05:23:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 18201-07 for ; Sat, 4 Dec 2010 09:23:47 +0000 (UTC) Received: from news.hub.org (news.hub.org [200.46.204.72]) by mail.postgresql.org (Postfix) with ESMTP id 6D83E1337B82 for ; Sat, 4 Dec 2010 05:23:47 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.14.4/8.14.4) with ESMTP id oB49NlQw017113 for ; Sat, 4 Dec 2010 05:23:47 -0400 (AST) (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.14.4/8.14.4/Submit) id oB49KLxt010520 for pgsql-performance@postgresql.org; Sat, 4 Dec 2010 05:20:21 -0400 (AST) (envelope-from news) From: John Papandriopoulos X-Newsgroups: pgsql.performance Subject: Re: Query-plan for partitioned UPDATE/DELETE slow and swaps vmem compared to SELECT Date: Sat, 04 Dec 2010 01:20:21 -0800 Organization: Hub.Org Networking Services Lines: 27 Message-ID: References: <14012.1291443654@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 In-Reply-To: <14012.1291443654@sss.pgh.pa.us> To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_RP_MATCHES_RCVD=-0.01, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201012/31 X-Sequence-Number: 41483 On 12/3/10 10:20 PM, Tom Lane wrote: > John Papandriopoulos writes: >> I've found that a k-ary table inheritance tree works quite well to >> reduce the O(n) CHECK constraint overhead [1] in the query planner >> when enabling partition constraint exclusion. > > Um ... you mean you're creating intermediate child tables for no reason > except to reduce the number of direct descendants of any one table? > That's an utter waste of time, because the first thing the planner will > do with an inheritance tree is flatten it. Just create *one* parent > table and make all the leaf tables direct children of it. > >> My machine swaps wildly when PostgreSQL plans an UPDATE or DELETE. > > This is a strong hint that you've got way too many child tables. Thanks for your advice, Tom. I've recreated the same example with just one parent table, and 4096 child tables. SELECT query planning is lightning fast as before; DELETE and UPDATE cause my machine to swap. What's different about DELETE and UPDATE here? If I've way too many child tables, why isn't the SELECT query plan causing the same large memory usage? Kindest, John