Skip to content

JsonPath filter too slow for big json #674

Open

Description

@zhangever

I have a big json(about 20MB), and it's a huge object which has many other objects as its children.
Each obj has a uid field, and i want to filter some obj out with uid.
If i get all uids, then redis will return immediately。

127.0.0.1:6379> json.get bigTree $..uid
[0,1,2,3,4,5,6,7,12,27,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,256,28,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,2.....

But when i add a filter, it took several minutes before return.

127.0.0.1:6379> json.get bigTree ..[?(@.uid==38)]
....

Here's the cost:

127.0.0.1:6379> slowlog get
2
1645782655
764868216
json.get
bigTree
..[?(@.uid==38)]
127.0.0.1:50480

1
1645781831
59106
json.get
bigTree
$..uid
127.0.0.1:50480

other examples:
$.childrens[*].childrens[?(@.uid==27)] is fast, but
$.childrens[*]..childrens[?(@.uid==27)] or $..childrens[*].childrens[?(@.uid==27)] is slow:

127.0.0.1:6379> slowlog get
2
1645783748
36327185
json.get
bigTree
$.childrens[*]..childrens[?(@.uid==27)]
127.0.0.1:50482

1
1645783587
32049986
json.get
bigTree
$..childrens[*].childrens[?(@.uid==27)]
127.0.0.1:50482

How can I make it faster?

Redis infos:

# Modules
module:name=search,ver=20205,api=1,filters=0,usedby=[],using=[ReJSON],options=[handle-io-errors]
module:name=ReJSON,ver=20004,api=1,filters=0,usedby=[search],using=[],options=[handle-io-errors]

Activity

  1. changed the title [-]JsonPath too slow for big json[/-] [+]JsonPath filter too slow for big json[/+] on Feb 25, 2022
  2. added
    q:performance
    on Feb 27, 2022
  3. gkorland commented on Feb 27, 2022

    @gkorland
    Contributor

    @zhangever can you please share an example JSON? if you can't share the 20MB please share an smaller example

  4. zhangever commented on Feb 27, 2022

    @zhangever
    Author

    @zhangever can you please share an example JSON? if you can't share the 20MB please share an smaller example

    Thanks for the reply.
    you can take the following json as a smaller example.
    sample.json.zip

  5. JoaoOxOc commented on Jun 17, 2022

    @JoaoOxOc

    @gkorland is it possible to use regex? tried $.data[?(/acc.*/.test(@.name))] but it always throws the json path error

  6. gkorland commented on Aug 9, 2022

    @gkorland
    Contributor

    JSONPath doesn't support regex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedq:performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions