Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aWXVR-0002Ve-F7 for pgsql-docs@arkaria.postgresql.org; Thu, 18 Feb 2016 22:57:05 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aWXVR-0006NB-1n for pgsql-docs@arkaria.postgresql.org; Thu, 18 Feb 2016 22:57:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aWXVP-0006L3-Qh for pgsql-docs@postgresql.org; Thu, 18 Feb 2016 22:57:03 +0000 Received: from mail-vk0-x22b.google.com ([2607:f8b0:400c:c05::22b]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aWXVM-0001wo-Hg for pgsql-docs@postgresql.org; Thu, 18 Feb 2016 22:57:03 +0000 Received: by mail-vk0-x22b.google.com with SMTP id c3so58986256vkb.3 for ; Thu, 18 Feb 2016 14:56:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=FsF8Pxrj2n6dsFqj6Z9eWef7ewRfcGRFE1W4f6tNI0o=; b=pvWJDRLoY7nTr4MaZYgR8RBEwH5tW0gW3zD1XrGJzq5Nkkn6VkWDtMZYqHNxSfO/Z5 dx456kngsmBaE9UmR65O0FluESWHPcR8KUGX8clo6ZmXv7EkoglxHgxZHIL26StgJEH6 HpZRpPHBf2XNp/joYC6/AmqKpC9quTb/PZ6+UgxM5ciRilrgfZcV13t3ovkq1C/4ZV3H CDUp2/NNXGBgKs8XA0iLwZ/OfpjvKPTIbYun4Uwx5gSptLvOkaP78g13BJrGctziuMQD Lghat5b3JVCQXKR/eRKCv2h9CaVod820oYEiwkLoSJ4gARAEl5STBhKeeLoim/O+cD1/ t74A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=FsF8Pxrj2n6dsFqj6Z9eWef7ewRfcGRFE1W4f6tNI0o=; b=iDdg2pmDKDdXvJHv84ML+JYrYjtrl7NkslsnF5kaMGolNUeGbMB8drT8Yi99JDuatn NlxFsNK6Vgu5TlplT8Di6Akn7ZMYAsljyJuQ0LoTC2X0Gtc8PDycJMOVYf/D8328fjwZ Ex9kLg32qXfGo5wJ+kz7t4Hj/Ze6Jd5zQJPcwujVVB2hFB07YqOhJbDdYEMsWz5sWFy0 jtOTkg4wJDAUTIbZ11q679/LHh8spvKBbPrCMdgv8pVitHljj+Xhioqwtcqea5kYtyid Zu0EJWUUMXkyScpjnCRLFNJfvUzbWI3o7U2RdOIxhIp67M8UTUU3lJhZfLdINz7HZao/ AtGQ== X-Gm-Message-State: AG10YOT1/JmitHkhkG+XT07V5Rv37LXJdeSxYNZF569am7zMNGxrjOerbH/0C2DcmQunUiEo0AdZOoeX4HND2xvE MIME-Version: 1.0 X-Received: by 10.31.6.143 with SMTP id 137mr8328120vkg.133.1455836218503; Thu, 18 Feb 2016 14:56:58 -0800 (PST) Received: by 10.31.154.145 with HTTP; Thu, 18 Feb 2016 14:56:58 -0800 (PST) In-Reply-To: <13291.1455825152@sss.pgh.pa.us> References: <56C5B2C7.7010604@nttcom.co.jp> <31925.1455817248@sss.pgh.pa.us> <377.1455818470@sss.pgh.pa.us> <10922.1455821371@sss.pgh.pa.us> <12435.1455823990@sss.pgh.pa.us> <13291.1455825152@sss.pgh.pa.us> Date: Thu, 18 Feb 2016 14:56:58 -0800 Message-ID: Subject: Re: [HACKERS] The number of bytes is stored in index_size of pgstatindex() ? From: Peter Geoghegan To: Tom Lane Cc: =?UTF-8?B?5aSn5aGa5oay5Y+4?= , pgsql-docs@postgresql.org, Pg Hackers Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org On Thu, Feb 18, 2016 at 11:52 AM, Tom Lane wrote: > It looks like this was done correctly to begin with, and I broke it in > d287818eb514d431b1a68e1f3940cd958f82aa34. Not sure what I was thinking :-( I think that you might not have simply changed the order in a totally misguided way back in 2008, as you seem to imply. Consider what this block does following your commit just now: ... else if (P_IGNORE(opaque)) indexStat.empty_pages++; /* this is the "half dead" state */ else if (P_ISLEAF(opaque)) { int max_avail; max_avail = BLCKSZ - (BLCKSZ - ((PageHeader) page)->pd_special + SizeOfPageHeaderData); indexStat.max_avail += max_avail; indexStat.free_space += PageGetFreeSpace(page); indexStat.leaf_pages++; /* * If the next leaf is on an earlier block, it means a * fragmentation. */ if (opaque->btpo_next != P_NONE && opaque->btpo_next < blkno) indexStat.fragments++; } ... I think that the P_ISLEAF() instrumentation of free space and fragments might still need to happen for deleted and/or half dead pages. Having looked at the 2008 commit d287818eb514d431 myself, ISTM that your intent might well have been to have that happen -- why else would any reasonable person have changed the order at all? The avg_leaf_density and leaf_fragmentation fields might now be argued to misrepresent the true picture. This is not clearly a departure from their documented behavior, if only because the descriptions are almost the same as the names of the fields themselves. If you think that the instrumentation of free space is the most useful possible behavior as of today, which it might well be, then you might have clarified that this behavior was your intent in today's commit, for example by updating the descriptions of the fields avg_leaf_density and leaf_fragmentation in the docs. Just a thought. -- Peter Geoghegan -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs