pgsql: Build de-escaped JSON strings in larger chunks during lexing - Mailing list pgsql-committers

From John Naylor
Subject pgsql: Build de-escaped JSON strings in larger chunks during lexing
Date
Msg-id E1oAkpK-002DWJ-IK@gemulon.postgresql.org
Whole thread Raw
Responses Re: pgsql: Build de-escaped JSON strings in larger chunks during lexing
List pgsql-committers
Build de-escaped JSON strings in larger chunks during lexing

During COPY BINARY with large JSONB blobs, it was found that half
the time was spent parsing JSON, with much of that spent in separate
appendStringInfoChar() calls for each input byte.

Add lookahead loop to json_lex_string() to allow batching multiple bytes
via appendBinaryStringInfo(). Also use this same logic when de-escaping
is not done, to avoid code duplication.

Report and proof of concept patch by Jelte Fennema, reworked by Andres
Freund and John Naylor

Discussion:
https://www.postgresql.org/message-id/CAGECzQQuXbies_nKgSiYifZUjBk6nOf2%3DTSXqRjj2BhUh8CTeA%40mail.gmail.com
Discussion:
https://www.postgresql.org/message-id/flat/PR3PR83MB0476F098CBCF68AF7A1CA89FF7B49@PR3PR83MB0476.EURPRD83.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/3838fa269c15706df2b85ce2d6af8aacd5611655

Modified Files
--------------
src/common/jsonapi.c | 58 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 39 insertions(+), 19 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pgsql: Only allow returning string types or bytea from json_serialize
Next
From: Thomas Munro
Date:
Subject: pgsql: Fix lock assertions in dshash.c.