I'm running into a warning when profiling a slow gremlin traversal.
WARNING: >> OrderGlobalStep([[[CoalesceStep([[VertexStep(IN,[view],edge), ProfileStep, NeptuneHasStep([isActive.eq(true)]), ProfileStep, EdgeVertexStep(OUT), ProfileStep, NeptuneHasStep([~id.eq(63b944e2-481d-42c8-a1a3-c0bc3ad24484)]), ProfileStep, RangeGlobalStep(0,1), ProfileStep, CountGlobalStep, ProfileStep], [ConstantStep(0), ProfileStep]]), ProfileStep], asc], [value(rekognitionModerationDate), desc], [value(createdDate), desc]]) << (or one of its children) is not supported natively yet
The profiler is reporting this step takes up 62% of the total execution time so I'd like to optimize it. Here is a simplified version of the complete traversal:
g.V()
.hasLabel("post")
.order()
.by(
__.coalesce(
__.inE("view")
.has("isActive", true)
.outV()
.hasId(userId)
.limit(1)
.count(),
__.constant(0)
),
order.asc
)
The goal is to output post
vertices that do not have an incoming view
edge first. In other words show posts that haven't been viewed by the requesting user, followed by posts they have viewed. The current traversal works but is very slow. How can I refactor this to be 'native' so it will execute faster?
Edit: Apparently the problem is that Neptune doesn't have native support for order().by()
with a custom comparator as explained here:
https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-step-support.html
I am still interested in ideas of how to refactor this for pure native support.