Re: jsonpath - Mailing list pgsql-hackers

From Alexander Korotkov
Subject Re: jsonpath
Date
Msg-id CAPpHfdsqJBF4SSzZ0su9fdq+xuNjaDrbeRWuvdPRCGX-bKWY2w@mail.gmail.com
Whole thread Raw
In response to Re: jsonpath  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
On Wed, Jan 30, 2019 at 9:36 AM Andres Freund <andres@anarazel.de> wrote:
> On 2019-01-30 07:34:00 +0300, Alexander Korotkov wrote:
> > Thank you for your review!  Let me answer some points of your review
> > while others will be answered later.
> >
> > On Wed, Jan 30, 2019 at 5:28 AM Andres Freund <andres@anarazel.de> wrote:
> > > On 2019-01-29 04:00:19 +0300, Alexander Korotkov wrote:
> > > > +/*****************************INPUT/OUTPUT*********************************/
> > >
> > > Why do we need this much code to serialize data that we initially got in
> > > serialized manner? Couldn't we just keep the original around?
> >
> > As I get, you concern related to fact that we have jsonpath in text
> > form (serialized) and convert it to the binary form (also serialized).
> > Yes, we should do so.  Otherwise, we would have to parse jsonpath for
> > each evaluation.  Basically, for the same reason we have binary
> > representation for jsonb.
>
> But why can't we keep the text around, instead of having all of that
> code for converting back?

Yeah, that's possible.  But now converting back to string is one of ways to test that jsonpath parsing is correct.  If we remove conversion back to string, this possibility would be also removed.  Also, we would loose way to normalize jsonpath, which is probably not that important.  As well it's generally ugly redundancy.  So, I can't say I like idea to save few hundreds lines of codes for this price.

> > > > +++ b/src/backend/utils/adt/jsonpath_exec.c
> > >
> > > Gotta say, I'm unenthusiastic about yet another execution engine in some
> > > PG subsystem.
> >
> > Better ideas?  I can imagine we can evade introduction of jsonpath
> > datatype and turn jsonpath into executor nodes.  But I hardly can
> > imagine you would be more enthusiastic about that :)
>
> Not executor nodes, I think it could be possible to put it into the
> expression evaluation codepaths, but it's probably too different to fit
> well (would get you JIT compilation of the whole thing tho).

Consider given example. We need to check some predicate for each JSON item, where predicate is given by expression and set of items is produced by another expression.  In order to fit this into expression evaluation, we probably need some kind of lamda functions there.  It seems unlikely for me that we want to implement that.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: Protect syscache from bloating with negative cache entries
Next
From: John Naylor
Date:
Subject: Re: WIP: Avoid creation of the free space map for small tables