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

Commit 0932658

Browse files
author
Nikita Glukhov
committed
Add GUC jsonb_partial_decompression
1 parent 026c7c2 commit 0932658

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/backend/utils/adt/jsonb_util.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ static JsonbValue *fillCompressedJsonbValue(CompressedJsonb *cjb,
134134
uint32 offset, JsonValue *result);
135135
static JsonbContainer *jsonbzDecompress(JsonContainer *jc);
136136

137+
bool jsonb_partial_decompression = true; /*GUC */
137138

138139
JsonValue *
139140
JsonValueUnpackBinary(const JsonValue *jbv)
@@ -2654,7 +2655,8 @@ jsonbzIteratorInit(JsonContainer *jc)
26542655
Jsonb *jb = (Jsonb *) cjb->datum->data;
26552656
JsonbContainerHeader *jbc = (JsonbContainerHeader *)((char *) jb + cjb->offset);
26562657

2657-
//CompressedDatumDecompressAll(cjb->datum);
2658+
if (!jsonb_partial_decompression)
2659+
CompressedDatumDecompressAll(cjb->datum);
26582660

26592661
return jsonbIteratorInitExt(jc, jbc, cjb);
26602662
}
@@ -2669,7 +2671,10 @@ jsonbzInit(JsonContainerData *jc, Datum value)
26692671
cjb->offset = offsetof(Jsonb, root);
26702672

26712673
CompressedDatumInit(cd, value);
2672-
CompressedDatumDecompress(cd, 256);
2674+
if (!jsonb_partial_decompression)
2675+
CompressedDatumDecompressAll(cd);
2676+
else
2677+
CompressedDatumDecompress(cd, 256);
26732678

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

src/backend/utils/misc/guc.c

+10
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
#include "utils/bytea.h"
102102
#include "utils/float.h"
103103
#include "utils/guc_tables.h"
104+
#include "utils/jsonb.h"
104105
#include "utils/memutils.h"
105106
#include "utils/pg_locale.h"
106107
#include "utils/pg_lsn.h"
@@ -2182,6 +2183,15 @@ static struct config_bool ConfigureNamesBool[] =
21822183
NULL, NULL, NULL
21832184
},
21842185

2186+
{
2187+
{"jsonb_partial_decompression", PGC_USERSET, DEVELOPER_OPTIONS,
2188+
gettext_noop("Use partial pglz decompression for jsonb."),
2189+
},
2190+
&jsonb_partial_decompression,
2191+
true,
2192+
NULL, NULL, NULL
2193+
},
2194+
21852195
/* End-of-list marker */
21862196
{
21872197
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL

src/include/utils/jsonb.h

+2
Original file line numberDiff line numberDiff line change
@@ -250,4 +250,6 @@ extern Datum jsonb_build_object_worker(int nargs, Datum *args, bool *nulls,
250250
extern Datum jsonb_build_array_worker(int nargs, Datum *args, bool *nulls,
251251
Oid *types, bool absent_on_null);
252252

253+
extern bool jsonb_partial_decompression; /* GUC */
254+
253255
#endif /* __JSONB_H__ */

0 commit comments

Comments
 (0)