Re: explain format json, unit for serialize and memory are different.

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: explain format json, unit for serialize and memory are different.
Date: 2024-05-14 06:16:26
Message-ID: CAApHDvo5uSuMxmArum36Wfsyx5hog8DciVmXqzCsVs7Mi0tLOg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 14 May 2024 at 17:40, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Mon, May 13, 2024 at 11:22:08AM +0200, Daniel Gustafsson wrote:
> > Since json (and yaml/xml) is intended to be machine-readable I think we use a
> > single unit for all values, and document this fact.
>
> Agreed with the documentation gap. Another thing that could be worth
> considering is to add the units aside with the numerical values, say:
> "Memory Used": {"value": 23432, "units": "bytes"}
>
> That would require changing ExplainProperty() so as the units are
> showed in some shape, while still being readable when parsed. I
> wouldn't recommend doing that in v17, but perhaps v18 could do better?

I think for v17, we should consider adding a macro to explain.c to
calculate the KB from bytes. There are other inconsistencies that it
would be good to address. We normally round up to the nearest kilobyte
with (bytes + 1023) / 1024, but if you look at what 06286709e did, it
seems to be rounding to the nearest without any apparent justification
as to why. It does (metrics->bytesSent + 512) / 1024.

show_memory_counters() could be modified to use the macro and show
kilobytes rather than bytes.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-05-14 06:18:16 Re: BitmapHeapScan streaming read user and prelim refactoring
Previous Message Michael Paquier 2024-05-14 06:03:22 Re: Fix resource leak (src/backend/libpq/be-secure-common.c)