Here is the output from attached bench:
n=10000
00:00:00.002628 jsonb := jsonb_set(jsonb, ARRAY[existing key], value);
00:00:00.002778 jsonb := jsonb_set(jsonb, ARRAY[new key], value);
00:00:00.002332 jsonb[existing key] := value;
00:00:00.002794 jsonb[new key] := value;
n=100000
00:00:00.042843 jsonb := jsonb_set(jsonb, ARRAY[existing key], value);
00:00:00.046515 jsonb := jsonb_set(jsonb, ARRAY[new key], value);
00:00:00.044974 jsonb[existing key] := value;
00:00:00.075429 jsonb[new key] := value;
n=1000000
00:00:00.420808 jsonb := jsonb_set(jsonb, ARRAY[existing key], value);
00:00:00.449622 jsonb := jsonb_set(jsonb, ARRAY[new key], value);
00:00:00.31834 jsonb[existing key] := value;
00:00:00.527904 jsonb[new key] := value;
Many thanks for clarifying.
Best regards,
Joel