gist_choose_bloat-0.1.patch
application/octet-stream
Filename: gist_choose_bloat-0.1.patch
Type: application/octet-stream
Part: 0
Message:
gistchoose vs. bloat
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: context
| File | + | − |
|---|---|---|
| src/backend/access/gist/gistutil.c | 13 | 0 |
*** a/src/backend/access/gist/gistutil.c
--- b/src/backend/access/gist/gistutil.c
***************
*** 372,387 **** gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
OffsetNumber maxoff;
OffsetNumber i;
OffsetNumber which;
! float sum_grow,
! which_grow[INDEX_MAX_KEYS];
GISTENTRY entry,
identry[INDEX_MAX_KEYS];
bool isnull[INDEX_MAX_KEYS];
maxoff = PageGetMaxOffsetNumber(p);
*which_grow = -1.0;
which = InvalidOffsetNumber;
- sum_grow = 1;
gistDeCompressAtt(giststate, r,
it, NULL, (OffsetNumber) 0,
identry, isnull);
--- 372,386 ----
OffsetNumber maxoff;
OffsetNumber i;
OffsetNumber which;
! float which_grow[INDEX_MAX_KEYS];
GISTENTRY entry,
identry[INDEX_MAX_KEYS];
bool isnull[INDEX_MAX_KEYS];
+ int same_count = 1;
maxoff = PageGetMaxOffsetNumber(p);
*which_grow = -1.0;
which = InvalidOffsetNumber;
gistDeCompressAtt(giststate, r,
it, NULL, (OffsetNumber) 0,
identry, isnull);
***************
*** 389,400 **** gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
Assert(maxoff >= FirstOffsetNumber);
Assert(!GistPageIsLeaf(p));
! for (i = FirstOffsetNumber; i <= maxoff && sum_grow; i = OffsetNumberNext(i))
{
int j;
IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
- sum_grow = 0;
for (j = 0; j < r->rd_att->natts; j++)
{
Datum datum;
--- 388,398 ----
Assert(maxoff >= FirstOffsetNumber);
Assert(!GistPageIsLeaf(p));
! for (i = FirstOffsetNumber; i <= maxoff; i = OffsetNumberNext(i))
{
int j;
IndexTuple itup = (IndexTuple) PageGetItem(p, PageGetItemId(p, i));
for (j = 0; j < r->rd_att->natts; j++)
{
Datum datum;
***************
*** 411,425 **** gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */
{
which = i;
which_grow[j] = usize;
! if (j < r->rd_att->natts - 1 && i == FirstOffsetNumber)
which_grow[j + 1] = -1;
- sum_grow += which_grow[j];
}
else if (which_grow[j] == usize)
! sum_grow += usize;
else
{
- sum_grow = 1;
break;
}
}
--- 409,429 ----
{
which = i;
which_grow[j] = usize;
! same_count = 1;
! if (j < r->rd_att->natts - 1)
which_grow[j + 1] = -1;
}
else if (which_grow[j] == usize)
! {
! if (j == r->rd_att->natts - 1)
! {
! same_count++;
! if ((rand() % same_count) == 0)
! which = i;
! }
! }
else
{
break;
}
}