From: | Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com> |
Cc: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Extract numeric filed in JSONB more effectively |
Date: | 2023-08-04 03:55:07 |
Message-ID: | CAKU4AWrvguHRmjgSbSvmsBFeBAZdyXNNE94SnBYkYEmFF-KbYA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi:
>
> can confirm the patch's jsonb_object_field_numeric is faster than
> pg_catalog."numeric"(jsonb).
>
Thanks for the confirmation.
>
> This function is not easy to find out...
>
> select jsonb_numeric(jsonb'{"a":11}'->'a'); --fail
>
jsonb_numeric is a prosrc rather than a proname, that's why you
can't call them directly.
select * from pg_proc where prosrc = 'jsonb_numeric';
select * from pg_proc where proname = 'jsonb_numeric';
It is bound to "numeric"(jsonb) cast, so we can call it with
a->'a'::numeric.
select numeric('{"a":11}'->'a'); --fail.
> select "numeric"('{"a":11}'::jsonb->'a'); --ok
>
The double quotes look weird to me. but it looks like a common situation.
select numeric('1'::int); -- failed.
select "numeric"('1'::int); -- ok.
--
Best Regards
Andy Fan
From | Date | Subject | |
---|---|---|---|
Next Message | Yugo NAGATA | 2023-08-04 04:03:25 | pgbench: allow to exit immediately when any client is aborted |
Previous Message | Pavel Stehule | 2023-08-04 03:54:15 | Re: Extract numeric filed in JSONB more effectively |