Re: Show lossy heap block info in EXPLAIN ANALYZE for bitmap heap scan

From: "Etsuro Fujita" <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: "'Robert Haas'" <robertmhaas(at)gmail(dot)com>
Cc: "'Amit Khandekar'" <amit(dot)khandekar(at)enterprisedb(dot)com>, "'pgsql-hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Show lossy heap block info in EXPLAIN ANALYZE for bitmap heap scan
Date: 2013-12-09 06:48:16
Message-ID: 009f01cef4aa$a39d8470$ead88d50$@etsuro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> On Fri, Dec 6, 2013 at 5:02 AM, Etsuro Fujita
<fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
> wrote:
> > Though at first I agreed on this, while working on this I start to
> > think information about (2) is enough for tuning work_mem. Here are
> > examples using a version under development, where "Bitmap Memory
> > Usage" means (peak) memory space used by a TIDBitmap, and "Desired"
> > means the memory required to guarantee non-lossy storage of a TID set,
> > which is shown only when the TIDBitmap has been lossified. (work_mem
> > = 1MB.)

> I'd be wary of showing a desired value unless it's highly likely to be
> accurate.

Thank you for the comments!

The desired value is accurately estimated based on (a) the total number of
exact/lossy pages stored in the TIDBitmap and (b) the following equation in
tbm_create(), except for the GIN case where lossy pages are added to the
TIDBitmap by tbm_add_page().

/*
* Estimate number of hashtable entries we can have within maxbytes. ...
*/
nbuckets = maxbytes /
(MAXALIGN(sizeof(HASHELEMENT)) + MAXALIGN(sizeof(PagetableEntry))
+ sizeof(Pointer) + sizeof(Pointer));

In the GIN case, however, the version under development has a risk of the
overestimation. (And in that case, in my understanding, we can't guarantee
non-lossy storage of the TIDBitmap any more.) So, for that case, I think to
change the message for the desired value a bit. I'll submit the patch
later.

Thanks,

Best regards,
Etsuro Fujita

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Khandekar 2013-12-09 06:57:27 Re: COPY table FROM STDIN doesn't show count tag
Previous Message KONDO Mitsumasa 2013-12-09 06:04:55 Re: Why we are going to have to go DirectIO