Skip to content

Commit 8c8ced1

Browse files
author
Nikita Glukhov
committed
Optimize jsonb returning, Json allocation
1 parent 0932658 commit 8c8ced1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/backend/utils/adt/jsonb_util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,9 @@ DatumGetJsonbPC(Datum datum, Json *tmp, bool copy)
27152715
datum = PointerGetDatum(pg_detoast_datum_copy(src));
27162716
}
27172717

2718+
if (!jsonb_partial_decompression)
2719+
return DatumGetJson(datum, &jsonbContainerOps, tmp);
2720+
27182721
CompressedDatumInit(&cd, datum);
27192722

27202723
if (!cd.compressed)

src/include/utils/json_generic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ typedef JsonContainer JsonbContainer;
110110
#else
111111
#define PG_GETARG_JSONB_P(n) DatumGetJsonbP(PG_GETARG_DATUM(n), alloca(sizeof(Json)), false) /* FIXME conditional alloca() */
112112
#endif
113-
#define PG_GETARG_JSONB_PC(n) DatumGetJsonbPC(PG_GETARG_DATUM(n), alloca(sizeof(Json)), false) /* FIXME conditional alloca() */
113+
#define PG_GETARG_JSONB_PC(n) DatumGetJsonbPC(PG_GETARG_DATUM(n), alloca(JsonAllocSize(16)) /* FIXME sizeof CompressedJsonb */, false)
114114
#define PG_GETARG_JSONB_P_COPY(x) DatumGetJsonbPCopy(PG_GETARG_DATUM(x))
115115

116116
#define PG_FREE_IF_COPY_JSONB(json, n) JsonFree(json)

0 commit comments

Comments
 (0)