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

Lines changed: 7 additions & 2 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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)
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