Re: WIP Patch: Add a function that returns binary JSONB as a bytea

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: WIP Patch: Add a function that returns binary JSONB as a bytea
Дата
Msg-id 20220624171202.vd7jf7n25nwvkkad@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: WIP Patch: Add a function that returns binary JSONB as a bytea  (John Naylor <john.naylor@enterprisedb.com>)
Список pgsql-hackers
Hi,

On 2022-06-24 14:33:00 +0700, John Naylor wrote:
> On Thu, Jun 23, 2022 at 9:06 PM Andres Freund <andres@anarazel.de> wrote:
> > It looks like there's quite a bit of low hanging fruits to optimize...
> 
> Yeah, if escapes and control characters are rare, adding an SSE2 fast
> path would give a boost to json_lex_string: check 16 bytes at a time
> for those chars (plus the ending double-quote).

The biggest thing I see is building the string in bigger chunks. Doing a
separate appendStringInfoChar() for each input character is obviously bad for
performance. I'd bet a good chunk of the time attributed to json_lex_string()
in Jelte's flamegraph is actually setting up the external function call to
appendStringInfoChar(). Which then proceeds to do a check whether the buffer
needs to be enlarged and maintains the trailing null byte on every call.

Greetings,

Andres Freund



В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Imseih (AWS), Sami"
Дата:
Сообщение: Re: [BUG] Panic due to incorrect missingContrecPtr after promotion
Следующее
От: Ekaterina Sokolova
Дата:
Сообщение: Re: [PATCH] Add extra statistics to explain for Nested Loop