Using dedup with Neptune

I remember once i came accross AWS Neptune optimization guide that i don't remember where is it now.

It mentions that .dedup() step is not optimized for Neptune which makes performance worse.

However, I have the following scenario where i need deduplicates and pagination at same time.

So the only possible way in mind is to do .dedup() then .range()
Or
.groupCount() then select keys then range()

But i am not sure if grouping does maintain the order all the time.

What could be done?
Solution
I guess what I'm getting at, is that I don't know of a way to make dedup() any more performant in that sort of query with Neptune's current implementation.

As far as pagination goes, have you tried using Neptune's Query Results Cache instead of making multiple range() calls? That would significantly decrease latency for subsequent calls as you paginate across the resuls: https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-results-cache.html
Overview of using the query results cache with Gremlin.
Was this page helpful?