On Sat, May 20, 2023 at 4:43 PM Marcos Pegoraro <mar...@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

>

Reply via email to