Search Postgresql Archives

jsonpath with @@ and iterating over arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have a question regarding the processing of arrays when using the "short jsonpath"
with the @@ operator.

E.g. when trying to "translate" this jsonpath

   where jsonb_path_exists(the_column, '$[*] ? (@.id == 42 && @.type == "foo")')

to be used with the @@ operator, then the "? (...)" cannot be used.

The following seems to work

   where the_column @@ '$[*].id == 42 && $[*].type == "foo"'


However, I have two questions regarding this:

1. is the order of the array processing guaranteed to be the same?

In other words: are @.id and @.type guaranteed to always refer to the keys of
the same element in the array?

2. is this less efficient that the jsonb_path_exists?

The jsonpath for the @@ operator contains two "iterator expression", and I wonder
if Postgres is smart enough to only iterate over the array once.


Thanks
Thomas







[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux