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

Reply via email to