Re: WIP: Avoid creation of the free space map for small tables

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: John Naylor <john(dot)naylor(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP: Avoid creation of the free space map for small tables
Date: 2019-02-20 11:09:09
Message-ID: CAA4eK1+3DCuosH4xJrOhiEcJpYOyc8efcAf+HRU=D5Our3GZKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 11, 2019 at 10:48 PM John Naylor
<john(dot)naylor(at)2ndquadrant(dot)com> wrote:
>
> On 2/9/19, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>
> > Shall we add a note to the docs of pg_freespacemap and
> > pgstattuple_approx indicating that for small relations, FSM won't be
> > created, so these functions won't give appropriate value?
>
> I've given this a try in 0002.
>

This looks mostly correct, but I have a few observations:
1.
- tuples.
+ tuples. Small tables don't have a free space map, so in that case
+ this function will report zero free space, likewise inflating the
+ estimated number of live tuples.

The last part of the sentence "likewise inflating the estimated number
of live tuples." seems incorrect to me because live tuples are
computed based on the pages scanned, live tuples in them and total
blocks in the relation. So, I think it should be "likewise inflating
the approximate tuple length".

2.
+ In addition, small tables don't have a free space map, so this function
+ will return zero even if free space is available.

Actually, the paragraph you have modified applies to both the
functions mentioned on that page. So instead of saying "this function
..", we can say "these functions .."

3.
* space from the FSM and move on.
+ * Note: If a relation has no FSM, GetRecordedFreeSpace() will report
+ * zero free space. This is fine for the purposes of approximation.
*/

It is better to have an empty line before Note: ...

I have modified the patch for the above observations and added a
commit message as well, see if it looks okay to you.

--
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
v3-0002-Document-that-functions-that-use-the-FSM-for-will.patch application/octet-stream 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2019-02-20 11:34:12 Re: WIP: Avoid creation of the free space map for small tables
Previous Message Sergei Kornilov 2019-02-20 10:53:37 bgwriter_lru_maxpages limits in PG 10 sample conf