Skip to content

Commit 5a3015c

Browse files
author
Nikita Glukhov
committed
Add GUC jsonb_partial_decompression
1 parent cae8663 commit 5a3015c

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/backend/utils/adt/jsonb_util.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ static JsonbValue *fillCompressedJsonbValue(CompressedJsonb *cjb,
159159
uint32 offset, JsonValue *result);
160160
static JsonbContainer *jsonbzDecompress(JsonContainer *jc);
161161

162-
bool jsonb_sort_field_values = true; /* GUC */
162+
bool jsonb_sort_field_values = true; /* GUC */
163+
bool jsonb_partial_decompression = true; /*GUC */
163164

164165
JsonValue *
165166
JsonValueUnpackBinary(const JsonValue *jbv)
@@ -2573,7 +2574,6 @@ CompressedDatumDecompress(CompressedDatum *cd, Size offset)
25732574
cd->decompressed_len = offset;
25742575
}
25752576

2576-
#if 0 /* unused */
25772577
static void
25782578
CompressedDatumDecompressAll(CompressedDatum *cd)
25792579
{
@@ -2588,7 +2588,6 @@ CompressedDatumDecompressAll(CompressedDatum *cd)
25882588
cd->decompressed_len = cd->total_len;
25892589
}
25902590
}
2591-
#endif
25922591

25932592
static void
25942593
jsonbzInitContainer(JsonContainerData *jc, CompressedJsonb *cjb, int len)
@@ -2844,7 +2843,8 @@ jsonbzIteratorInit(JsonContainer *jc)
28442843
Jsonb *jb = (Jsonb *) cjb->datum->data;
28452844
JsonbContainer *jbc = (JsonbContainer *)((char *) jb + cjb->offset);
28462845

2847-
//CompressedDatumDecompressAll(cjb->datum);
2846+
if (!jsonb_partial_decompression)
2847+
CompressedDatumDecompressAll(cjb->datum);
28482848

28492849
return jsonbIteratorInit(jc, jbc, cjb);
28502850
}
@@ -2859,7 +2859,10 @@ jsonbzInit(JsonContainerData *jc, Datum value)
28592859
cjb->offset = offsetof(Jsonb, root);
28602860

28612861
CompressedDatumInit(cd, value);
2862-
CompressedDatumDecompress(cd, 256);
2862+
if (!jsonb_partial_decompression)
2863+
CompressedDatumDecompressAll(cd);
2864+
else
2865+
CompressedDatumDecompress(cd, 256);
28632866

28642867
jsonbzInitContainer(jc, cjb, VARSIZE_ANY_EXHDR(cd->data)); // cd->total_len - VARHDRSZ
28652868
}

src/backend/utils/misc/guc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,6 +2046,16 @@ static struct config_bool ConfigureNamesBool[] =
20462046
NULL, NULL, NULL
20472047
},
20482048

2049+
{
2050+
{"jsonb_partial_decompression", PGC_USERSET, DEVELOPER_OPTIONS,
2051+
gettext_noop("Use partial pglz decompression for jsonb."),
2052+
},
2053+
&jsonb_partial_decompression,
2054+
true,
2055+
NULL, NULL, NULL
2056+
},
2057+
2058+
20492059
/* End-of-list marker */
20502060
{
20512061
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL

src/include/utils/jsonb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ extern void JsonbHashScalarValueExtended(const JsonbValue *scalarVal,
413413
extern int reserveFromBuffer(StringInfo buffer, int len);
414414
extern void appendToBuffer(StringInfo buffer, const void *data, int len);
415415

416-
extern bool jsonb_sort_field_values; /* GUC */
416+
extern bool jsonb_sort_field_values; /* GUC */
417+
extern bool jsonb_partial_decompression; /* GUC */
417418

418419
#endif /* __JSONB_H__ */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy