Skip to content

Instantly share code, notes, and snippets.

@spmallette
Last active February 23, 2024 13:52
Show Gist options
  • Save spmallette/3dc8ae73f9f26060fa163ef43affcef7 to your computer and use it in GitHub Desktop.
Save spmallette/3dc8ae73f9f26060fa163ef43affcef7 to your computer and use it in GitHub Desktop.
// * Improved performance of the application of `FilterRankingStrategy` for large traversals with deeply nested traversals by improving the cache operation.
g.V().as("n").
where(__.or(__.select("n").hasLabel("software"), __.select("n").hasLabel("person"))).
select("n").by("name")
before
FilterRankingStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
after
FilterRankingStrategy [O] [GraphStep(vertex,[]), TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])])@[n], SelectOneStep(last,n,value(name))]
gremlin> g.V().as("n").
......1> where(__.or(__.select("n").hasLabel("software"), __.select("n").hasLabel("person"))).
......2> select("n").by("name").explain()
==>Traversal Explanation
==============================================================================================================================================================================================================================================================
Original Traversal [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
ConnectiveStrategy [D] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
RepeatUnrollStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
CountStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
IdentityRemovalStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
MatchPredicateStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
FilterRankingStrategy [O] [GraphStep(vertex,[]), TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])])@[n], SelectOneStep(last,n,value(name))]
InlineFilterStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
EarlyLimitStrategy [O] [GraphStep(vertex,[]), OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])@[n], SelectOneStep(last,n,value(name))]
IncidentToAdjacentStrategy [O] [GraphStep(vertex,[]), OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])@[n], SelectOneStep(last,n,value(name))]
AdjacentToIncidentStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
PathRetractionStrategy [O] [GraphStep(vertex,[]), OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])@[n], SelectOneStep(last,n,value(name))]
LazyBarrierStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
ByModulatorOptimizationStrategy [O] [GraphStep(vertex,[]), OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])@[n], SelectOneStep(last,n,value(name))]
TinkerGraphCountStrategy [P] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
TinkerGraphStepStrategy [P] [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
ProfileStrategy [F] [TinkerGraphStep(vertex,[]), OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])@[n], SelectOneStep(last,n,value(name))]
StandardVerificationStrategy [V] [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
Final Traversal [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
gremlin> g.V().as("n").
......1> where(__.or(__.select("n").hasLabel("software"), __.select("n").hasLabel("person"))).
......2> select("n").by("name").explain()
==>Traversal Explanation
==============================================================================================================================================================================================================================================================
Original Traversal [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
ConnectiveStrategy [D] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
RepeatUnrollStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
CountStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
IdentityRemovalStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
MatchPredicateStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
FilterRankingStrategy [O] [GraphStep(vertex,[])@[n], TraversalFilterStep([OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]])]), SelectOneStep(last,n,value(name))]
InlineFilterStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
EarlyLimitStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
IncidentToAdjacentStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
AdjacentToIncidentStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
PathRetractionStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
LazyBarrierStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
ByModulatorOptimizationStrategy [O] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
TinkerGraphCountStrategy [P] [GraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
TinkerGraphStepStrategy [P] [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
ProfileStrategy [F] [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
StandardVerificationStrategy [V] [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
Final Traversal [TinkerGraphStep(vertex,[])@[n], OrStep([[SelectOneStep(last,n,null), HasStep([~label.eq(software)])], [SelectOneStep(last,n,null), HasStep([~label.eq(person)])]]), SelectOneStep(last,n,value(name))]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment