public inbox for [email protected]
help / color / mirror / Atom feedFrom: Pavel Stehule <[email protected]>
To: PostgreSQL Hackers <[email protected]>
Subject: proposal: plpgsql - FOREACH t IN JSON ARRAY expr
Date: Sat, 24 Jan 2026 08:10:36 +0100
Message-ID: <CAFj8pRB858EmA2xqaWQMUs_bYmLNZY8eBS2zP+wrg0vyT97gDA@mail.gmail.com> (raw)
Hi,
last year I did a performance audit of some applications and I found a new
relatively common pattern - iteration over jsonb arrays. Because PL/pgSQL
doesn't support this iteration directly, they used some combinations of
jsonb_array_elements function and FOR IN SELECT.
The overhead of this can be relatively high, and I think we can support
FOREACH json(b) arrays without some high cost.
My idea is a support of syntax
FOREACH target IN JSON ARRAY expression LOOP .. END LOOP
target can be a scalar variable of any type - we can use cast rules used in
JSON_TABLE
What do you think about this proposal?
Regards
Pavel
view thread (2+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: proposal: plpgsql - FOREACH t IN JSON ARRAY expr
In-Reply-To: <CAFj8pRB858EmA2xqaWQMUs_bYmLNZY8eBS2zP+wrg0vyT97gDA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox