Re: cache type info in json_agg and friends

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: cache type info in json_agg and friends
Дата
Msg-id 20150914194127.GF55767@alvherre.pgsql
обсуждение исходный текст
Ответ на cache type info in json_agg and friends  (Andrew Dunstan <andrew@dunslane.net>)
Ответы Re: cache type info in json_agg and friends  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
Andrew Dunstan wrote:

> Currently, json_agg, jsonb_agg, json_object_agg and jsonb_object_agg do type
> classification on their arguments on each call to the transition function.
> This is quite unnecessary, as the argument types won't change. This patch
> remedies the defect by caching the necessary values in the aggregate state
> object.

Seems a reasonable idea to me.  This is 9.6 only, right?

What's the reason for this pattern?

!       json_categorize_type(val_type,&tcategory, &outfuncoid);
!       state->val_category = tcategory;
!       state->val_output_func = outfuncoid;

I think you could just as well call json_categorize_type() with the
final pointer values, and save the two separate variables, as there is
no gain in clarity or ease of reading; I mean

!       json_categorize_type(tmptyp, &state->val_category, &state->val_output_func);

Also, and this is not new in this patch, this code reuses a variable
named "val_type" for both values and keys, which reads a bit odd.

-- 
Álvaro Herrera                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



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

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: cache type info in json_agg and friends
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: cache type info in json_agg and friends