ContainsAny query optimization

18 views
Skip to first unread message

Gluber

unread,
Dec 5, 2023, 9:43:49 AM12/5/23
to RavenDB - an awesome database
Hi

I have a question, currently we build a static index where each entry looks like the following


   NodeIds: ["x","y","z"] 
}

etc.. 

I need to query for all entries with a contains any:

MyNodeIds = [......]

query.Where(q => NodeIds.ContainsAny(MyNodeIds));

So far so good...

However MyNodeIds is stored in another document, and we're basically roundtripping this needlessly... 

e.g Pseudocode:

MyNodeIds = LoadDocument<D1>("..:").MyNodeIds
query.Where(q => q.NodeIds.ContainsAny(MyNodeIds)


MyNodeIds can become quite large ( e.g 4k entries ) 

Is there a way to save the roundtrip e.g.

query.Where(q => q.NodeIds.ContainsAny(LoadDocument<D1>("").MyNodeIds)

so that the node ids stay sever side and need not be transferred ? 
( I know that the above is just pseudo code and that any api for that would look quite different ) 

Also please node that this approach with contains any comes from the fact that 
we have to prevent a cartesian product in our indices, so expanding the index 
to fan out does not help. 

Egor Shamanaev

unread,
Dec 7, 2023, 6:39:57 AM12/7/23
to RavenDB - an awesome database
this google group is achieved, you can reask the question on github discussions: https://github.com/ravendb/ravendb/discussions
Reply all
Reply to author
Forward
0 new messages