Re: Extract numeric filed in JSONB more effectively

From: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
To: jian he <jian(dot)universality(at)gmail(dot)com>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Extract numeric filed in JSONB more effectively
Date: 2023-08-07 11:51:18
Message-ID: CAKU4AWpza653bvyzuWvvokx-56agX5-Ws4zov=UzWpZpG017CA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jian:

Thanks for the review!

compared with jsonb_numeric. I am wondering if you need a free *jb.
> elog(INFO,"jb=%p arg pointer=%p ", jb, PG_GETARG_POINTER(0));
> says there two are not the same.
>

Thanks for pointing this out, I am not sure what to do right now.
Basically the question is that shall we free the memory which
is allocated in a function call. The proof to do it is obvious, but the
proof to NOT do it may be usually the memory is allocated under
ExprContext Memorycontext, it will be reset once the current
tuple is proceed, and MemoryContextReset will be more effective
than pfrees;

I checked most of the functions to free its memory, besides the
ones you mentioned, numeric_gt/ne/xxx function also free them
directly. But the functions like jsonb_object_field_text,
jsonb_array_element, jsonb_array_element_text don't.

I'd like to hear more options from more experienced people,
this issue also confused me before. and I'm neutral to this now.
after we get an agreement on this, I will update the patch
accordingly.

--
Best Regards
Andy Fan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2023-08-07 12:15:22 Re: [PoC] Reducing planning time when tables have many partitions
Previous Message Alvaro Herrera 2023-08-07 11:25:04 Re: [BUG] Fix DETACH with FK pointing to a partitioned table fails