Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b402076

Browse files
author
Nikita Glukhov
committed
Add GUC jsonb_partial_decompression
1 parent e0a9476 commit b402076

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)
@@ -2636,7 +2637,6 @@ CompressedDatumDecompress(CompressedDatum *cd, Size offset)
26362637
cd->decompressed_len = offset;
26372638
}
26382639

2639-
#if 0 /* unused */
26402640
static void
26412641
CompressedDatumDecompressAll(CompressedDatum *cd)
26422642
{
@@ -2651,7 +2651,6 @@ CompressedDatumDecompressAll(CompressedDatum *cd)
26512651
cd->decompressed_len = cd->total_len;
26522652
}
26532653
}
2654-
#endif
26552654

26562655
static void
26572656
jsonbzInitContainer(JsonContainerData *jc, CompressedJsonb *cjb, int len)
@@ -2907,7 +2906,8 @@ jsonbzIteratorInit(JsonContainer *jc)
29072906
Jsonb *jb = (Jsonb *) cjb->datum->data;
29082907
JsonbContainer *jbc = (JsonbContainer *)((char *) jb + cjb->offset);
29092908

2910-
//CompressedDatumDecompressAll(cjb->datum);
2909+
if (!jsonb_partial_decompression)
2910+
CompressedDatumDecompressAll(cjb->datum);
29112911

29122912
return jsonbIteratorInit(jc, jbc, cjb);
29132913
}
@@ -2922,7 +2922,10 @@ jsonbzInit(JsonContainerData *jc, Datum value)
29222922
cjb->offset = offsetof(Jsonb, root);
29232923

29242924
CompressedDatumInit(cd, value);
2925-
CompressedDatumDecompress(cd, 256);
2925+
if (!jsonb_partial_decompression)
2926+
CompressedDatumDecompressAll(cd);
2927+
else
2928+
CompressedDatumDecompress(cd, 256);
29262929

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

src/backend/utils/misc/guc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,16 @@ static struct config_bool ConfigureNamesBool[] =
20942094
NULL, NULL, NULL
20952095
},
20962096

2097+
{
2098+
{"jsonb_partial_decompression", PGC_USERSET, DEVELOPER_OPTIONS,
2099+
gettext_noop("Use partial pglz decompression for jsonb."),
2100+
},
2101+
&jsonb_partial_decompression,
2102+
true,
2103+
NULL, NULL, NULL
2104+
},
2105+
2106+
20972107
/* End-of-list marker */
20982108
{
20992109
{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)