Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUdSX-0004Dq-Ix for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Dec 2017 19:03:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUdSX-0007KT-6S for pgsql-hackers@arkaria.postgresql.org; Thu, 28 Dec 2017 19:03:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eUdSW-0007JI-Ss for pgsql-hackers@lists.postgresql.org; Thu, 28 Dec 2017 19:03:17 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eUdST-0005qf-OX for pgsql-hackers@postgresql.org; Thu, 28 Dec 2017 19:03:15 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id C4DC0206B5; Thu, 28 Dec 2017 14:03:12 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute7.internal (MEProxy); Thu, 28 Dec 2017 14:03:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=MVIuaa cpgvPf3Cq3aett2LZ9cuuymgg00eCmt8sR/xU=; b=GQALWcdUz6oj57T/vmA/RK qGmASDIb5XOx/mFfEgzTWmD8+giLowqscycBXVCr90dxnBO8ei74oni2otB2Bfea i7PCpLcLMnATbYgX3c7tqXGMvMd+XWsLQDHvd4myLrFoiPsGCuHFJQW79dqpd8R7 +m983RRW65foCVv7aNJoh7d6cROfRPO8BW39/x4XJmVWr1iubFIxkTGOEh8QueZh N9ixfBm9vJklMTdY70n0QvmOfHr7CcwW6GUtdUWVkucdhSi8qLC1Z+F1iCkq4gcK 7lyU7y0gywKPqgSHezBQ1jdlaOirH26YW2zVJ61LRUZV687iuQ97CzLGqb6RhMiA == X-ME-Sender: Received: from april.local (c-73-13-66-39.hsd1.pa.comcast.net [73.13.66.39]) by mail.messagingengine.com (Postfix) with ESMTPA id 790C824235; Thu, 28 Dec 2017 14:03:12 -0500 (EST) Subject: Re: pg_(total_)relation_size and partitioned tables To: Amit Langote , Michael Paquier , David Rowley References: <495cec7e-f8d9-7e13-4807-90dbf4eec4ea@lab.ntt.co.jp> <1a78dea4-36b7-afb7-b3f3-1b4ff319fbb4@lab.ntt.co.jp> Cc: Robert Haas , Pg Hackers From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Thu, 28 Dec 2017 14:03:11 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1a78dea4-36b7-afb7-b3f3-1b4ff319fbb4@lab.ntt.co.jp> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/18/17 00:17, Amit Langote wrote: > I agree with the Robert's point which both David and Michael seem to agree > with that we shouldn't really be changing what pg_relation_size() is doing > under the covers. And I guess the same for pg_table_size(), too. Both of > those functions and their siblings work with relations that possess > on-disk structures and have associated relations (TOAST, indexes) that in > turn possess on-disk structures. It seems quite clearly documented as > such. Partitioned tables are different in that they neither possess > on-disk structures nor have any relations (TOAST, indexes) associated > directly with them. Instead, they have partitions that are the relations > that aforementioned dbsize.c functions are familiar with. Here is another idea. If we had a function pg_partition_root(regclass) returns regclass (returning itself for non-partitioned relations), then users can easily construct queries to get the results they want in different shapes, e.g., select pg_partition_root(c.oid), c.relname, pg_table_size(c.oid) from pg_class c order by 1 select pg_partition_root(c.oid), sum(pg_table_size(c.oid)) from pg_class c group by 1 -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services