Re: [HACKERS] PATCH: multivariate histograms and MCV lists

David Rowley <david.rowley@2ndquadrant.com>

From: David Rowley <david.rowley@2ndquadrant.com>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>, Dean Rasheed <dean.a.rasheed@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, Michael Paquier <michael@paquier.xyz>, Andres Freund <andres@anarazel.de>, Thomas Munro <thomas.munro@enterprisedb.com>, Bruce Momjian <bruce@momjian.us>, Mark Dilger <hornschnorter@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2019-03-13T06:37:45Z
Lists: pgsql-hackers
On Wed, 13 Mar 2019 at 17:20, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
> bms_member_index seems working differently than maybe expected.
>
>  bms_member_index((2, 4), 0) => 0, (I think) should be -1
>  bms_member_index((2, 4), 1) => 0, should be -1
>  bms_member_index((2, 4), 2) => 0, should be 0
>  bms_member_index((2, 4), 3) => 1, should be -1
>  bms_member_index((2, 4), 4) => 1, should be 1
>  bms_member_index((2, 4), 5) => 2, should be -1
>  bms_member_index((2, 4), 6) => 2, should be -1
> ...
>  bms_member_index((2, 4), 63) => 2, should be -1
>  bms_member_index((2, 4), 64) => -1, correct
>
> It works correctly only when x is a member - the way the function
> is maybe actually used in this patch -, or needs to change the
> specifiction (or the comment) of the function.

Looks like:

+ if (wordnum >= a->nwords)
+ return -1;

should be:

+ if (wordnum >= a->nwords ||
+ (a->word[wordnum] & ((bitmapword) 1 << bitnum)) == 0)
+ return -1;

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


Commits

  1. Convert pre-existing stats_ext tests to new style

  2. Add support for multivariate MCV lists

  3. Improve ANALYZE's strategy for finding MCVs.

  4. Clone extended stats in CREATE TABLE (LIKE INCLUDING ALL)

  5. Try again to fix accumulation of parallel worker instrumentation.

  6. Adjust psql \d query to avoid use of @> operator.

  7. Message style fixes

  8. Add security checks to selectivity estimation functions