orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

Limit # of edges traversed in a fetchPlan

Open thecyman opened this issue 12 years ago • 4 comments

So far as I understand, we can limit the depth of a fetchPlan, but we cannot limit the number of edges traversed. Example: If there's a social network app, with a class Post. One Post object can have 2,000 comments. But often you'll only want to fetchPlan the first 3 comments (plus fetch the user object of the author).

For example, here is a working fetchPlan that would return 1000 comments: SELECT from SOME_POST_RID FETCHPLAN 'out_PostHasComment.in.in_UserWroteComment.out:1 in_UserWrotePost.out:1'

If would be great if we could do something like this: (NOTE: The syntax I made up is inconsistent and only there to demonstrate what I need to do.) SELECT from SOME_POST_RID FETCHPLAN 'out_PostHasComment.in(LIMIT 3 ORDER BY createdAt DESC).in_UserWroteComment.out:1 in_UserWrotePost.out:1 in_UserLikesPost.out:1'

I was thinking of using a TRAVERSE, but I was told this will not work in my situation: https://groups.google.com/forum/#!topic/orient-database/RELRoJz7U_E

thecyman avatar Nov 26 '14 19:11 thecyman

+1 - Without this feature, we have to write custom javascript functions to limit the number of edges for all our paging requests - Any idea when this feature can be made available?

alpeshgaglani avatar Apr 26 '15 05:04 alpeshgaglani

We have exactly the same problem. This feature is definitely a must have.

red-0ne avatar May 09 '15 09:05 red-0ne

I think this could be supported by the new MATCH statement. @luigidellaquila this is yours ;-)

lvca avatar Jun 18 '15 15:06 lvca

@lvca don't spoiler too much ;-) Anyway yes, it's definitely a good idea. I just would like to add some additional details, like traversal strategy (eg. depth/breadth first, preorder, postorder)

luigidellaquila avatar Jun 19 '15 16:06 luigidellaquila