Re: CTE, lateral or jsonb_object_agg ?

Поиск
Список
Период
Сортировка
От Dominique Devienne
Тема Re: CTE, lateral or jsonb_object_agg ?
Дата
Msg-id CAFCRh-_R6GxFm52ixS4GJPqWWA0A7XFNtYytqJoMVS0uYXOe+A@mail.gmail.com
обсуждение исходный текст
Ответ на CTE, lateral or jsonb_object_agg ?  (Marcos Pegoraro <marcos@f10.com.br>)
Список pgsql-general
On Sat, May 20, 2023 at 4:43 PM Marcos Pegoraro <marcos@f10.com.br> wrote:
I have a table like pg_settings, so records have name and value.

Hi. Maybe I'm missing something, but why aren't you simply doing:

    select name, varvalue from sys_var where name = any($1)

and binding your 4 (in your examples) or 10 or 1 name(s) as a text array (i.e. text[])?
With a prepared statement you plan only once.

You can also avoid selecting names by unnest'ing the text-array with ordinality
and join+sort on it, to get the values in name order (i.e. same order as $1 you control).
See my recent thread where I learned about that technique.

Generating SQL text dynamically when you can avoid it with proper binding
and appropriate SQL is leaving performance on the table IMHO. --DD

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

Предыдущее
От: Tiffany Thang
Дата:
Сообщение: Re: Profiling a function call
Следующее
От: Ron
Дата:
Сообщение: Re: DBeaver postgres localhost access