pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Geoghegan <pg@heroku.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: 大塚憲司 <otsuka.kenji@nttcom.co.jp>
Cc: pgsql-docs@postgresql.org, Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: [HACKERS] The number of bytes is stored in index_size of pgstatindex() ?
Date: Thu, 18 Feb 2016 14:56:58 -0800
Message-ID: <CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com> (raw)
In-Reply-To: <13291.1455825152@sss.pgh.pa.us>
References: <56C5B2C7.7010604@nttcom.co.jp>
	<31925.1455817248@sss.pgh.pa.us>
	<CAM3SWZQtQ2WDGRqa2g_dbfHuu9CebfWvJ_XpXggFoFG1mUYzXw@mail.gmail.com>
	<377.1455818470@sss.pgh.pa.us>
	<CAM3SWZT2UaCTqpd71uhUVQN7b7k4treyzGyQLpv4N=TYU=F7tg@mail.gmail.com>
	<10922.1455821371@sss.pgh.pa.us>
	<CAM3SWZRLfCayENUVE2SqyeAiYKLFO7a7cHK4YbJGj55ZQ2i35w@mail.gmail.com>
	<12435.1455823990@sss.pgh.pa.us>
	<13291.1455825152@sss.pgh.pa.us>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>

On Thu, Feb 18, 2016 at 11:52 AM, Tom Lane <tgl@sss.pgh.pa.us> 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



view thread (19+ messages)  latest in thread

Message-ID: <CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com>
Permalink:  ../CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com/
Also on:    postgresql.org/message-id/CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-docs@postgresql.org
  Cc: pg@heroku.com, tgl@sss.pgh.pa.us, otsuka.kenji@nttcom.co.jp, pgsql-hackers@postgresql.org
  Subject: Re: [HACKERS] The number of bytes is stored in index_size of pgstatindex() ?
  In-Reply-To: <CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com>
  References: <56C5B2C7.7010604@nttcom.co.jp> <31925.1455817248@sss.pgh.pa.us> <CAM3SWZQtQ2WDGRqa2g_dbfHuu9CebfWvJ_XpXggFoFG1mUYzXw@mail.gmail.com> <377.1455818470@sss.pgh.pa.us> <CAM3SWZT2UaCTqpd71uhUVQN7b7k4treyzGyQLpv4N=TYU=F7tg@mail.gmail.com> <10922.1455821371@sss.pgh.pa.us> <CAM3SWZRLfCayENUVE2SqyeAiYKLFO7a7cHK4YbJGj55ZQ2i35w@mail.gmail.com> <12435.1455823990@sss.pgh.pa.us> <13291.1455825152@sss.pgh.pa.us> <CAM3SWZTUNXgzCfVsYSFP44cRo4K-93BPDC+gEbm_WveFdTKmnA@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox