| From: | Andy Fan <zhihuifan1213(at)163(dot)com> |
|---|---|
| To: | Haibo Yan <tristan(dot)yim(at)gmail(dot)com> |
| Cc: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Amit Langote <amitlangote09(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, jian he <jian(dot)universality(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Extract numeric filed in JSONB more effectively |
| Date: | 2026-04-07 06:13:35 |
| Message-ID: | 873417fgc0.fsf@163.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Haibo,
> I’d like to continue pushing this patch forward.
> Based on the earlier discussion, I reworked the patch into a smaller
> stage-1 version with a narrower scope and a simpler rewrite
> strategy. ..
> and does not yet try to cover array/path extraction or integer/float
> typed extractors.
Thanks for working on this. I did a quick comparison between this
version and my last patch v18 [1], here is the difference.
My previous v18[1]: 542 insertions(+), 59 deletions(-)
Your patch: 543 insertions(+), 5 deletions(-)
However as what you have realized, your current patch still lack of many
optimizations, Not only the integer/float stuff, but also many
functions, e.g. jsonb_array_element, jsonb_extract_path,
jsonb_path_query and jsonb_path_query_first. After considering this,
what patch will look like in your approach? I guess you can see many
duplications. Less code doesn't always mean better, but I think this
still be a key consideration to address/check.
> I also ran a small microbenchmark to isolate the cast-over-object-field path. On my setup, the current patch shows the following gains:
> Query Before After Speedup
> --------------------------------------------------------------------------------
> SELECT sum((j->'n')::numeric) FROM t 118.028 ms 56.082 ms 2.10x
> SELECT count(*) FROM t WHERE (j->'b')::bool 115.665 ms 51.945 ms 2.23x
> --------------------------------------------------------------------------------
Thanks for running the test.
[1] https://www.postgresql.org/message-id/87ttk0lgcx.fsf%40163.com
--
Best Regards
Andy Fan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-04-07 06:27:53 | Re: Refactor query normalization into core query jumbling |
| Previous Message | Michael Paquier | 2026-04-07 06:11:32 | Re: DOCS: typo on CLUSTER page |