Yuancheng created TINKERPOP-2829:
------------------------------------

             Summary: `AS` clause may slow down the query which ups to 60x times
                 Key: TINKERPOP-2829
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2829
             Project: TinkerPop
          Issue Type: Improvement
          Components: server
    Affects Versions: 3.6.1, 3.5.0
            Reporter: Yuancheng


A potential performance bug or missed optimization exists when handling `AS` 
clause. 

 
{code:java}
The as()-step is not a real step, but a "step modulator" similar to by() and 
option(). With as(), it is possible to provide a label to the step that can 
later be accessed by steps and data structures that make use of such labels — 
e.g., select(), match(), and path {code}
It seems that `AS` should not impact the performance in this way:

 

 
{code:java}
## PROFILE VERSION: 3.6.1 ##
## DATASET: 
https://raw.githubusercontent.com/krlawrence/graph/master/sample-data/air-routes-latest.graphml

gremlin> g.V().bothE().otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.973     1.03
VertexStep(BOTH,vertex)                                           115290      
115290          32.040    16.75
NoOpBarrierStep(2500)                                             115290       
13560          24.857    13.00
VertexStep(BOTH,vertex)                                         20833868      
507044         132.407    69.22
                                            >TOTAL                     -        
   -         191.279        -
gremlin> g.V().bothE().otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.974     1.06
VertexStep(BOTH,vertex)                                           115290      
115290          31.432    16.89
NoOpBarrierStep(2500)                                             115290       
13560          24.896    13.38
VertexStep(BOTH,vertex)                                         20833868      
507044         127.837    68.68
                                            >TOTAL                     -        
   -         186.141        -
gremlin> g.V().as('x').bothE().otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])@[x]                                      3749        
3749           3.461     0.08
VertexStep(BOTH,vertex)                                           115290      
115290          30.815     0.67
VertexStep(BOTH,vertex)                                         20833868    
20833868        4566.277    99.25
                                            >TOTAL                     -        
   -        4600.554        -
gremlin> g.V().as('x').bothE().otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])@[x]                                      3749        
3749           3.371     0.07
VertexStep(BOTH,vertex)                                           115290      
115290          28.952     0.63
VertexStep(BOTH,vertex)                                         20833868    
20833868        4546.777    99.29
                                            >TOTAL                     -        
   -        4579.101        -
gremlin> g.V().bothE().as('x').otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           2.710     0.05
VertexStep(BOTH,edge)@[x]                                         115290      
115290          37.150     0.73
EdgeOtherVertexStep                                               115290      
115290          45.935     0.90
VertexStep(BOTH,vertex)                                         20833868    
20833868        5021.292    98.32
                                            >TOTAL                     -        
   -        5107.089        -
gremlin> g.V().bothE().as('x').otherV().bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           2.767     0.05
VertexStep(BOTH,edge)@[x]                                         115290      
115290          36.794     0.71
EdgeOtherVertexStep                                               115290      
115290          46.275     0.89
VertexStep(BOTH,vertex)                                         20833868    
20833868        5085.313    98.34
                                            >TOTAL                     -        
   -        5171.151        -
gremlin> g.V().bothE().otherV().as('x').bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.747     0.82
VertexStep(BOTH,vertex)                                           115290      
115290          34.879    16.45
NoOpBarrierStep(2500)@[x]                                         115290       
13560          29.119    13.74
VertexStep(BOTH,vertex)                                         20833868      
507044         146.249    68.99
                                            >TOTAL                     -        
   -         211.995        -
gremlin> g.V().bothE().otherV().as('x').bothE().otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.995     1.00
VertexStep(BOTH,vertex)                                           115290      
115290          33.906    17.03
NoOpBarrierStep(2500)@[x]                                         115290       
13560          29.064    14.60
VertexStep(BOTH,vertex)                                         20833868      
507044         134.170    67.38
                                            >TOTAL                     -        
   -         199.136        -
gremlin> g.V().bothE().otherV().bothE().as('x').otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           2.594     0.02
VertexStep(BOTH,vertex)                                           115290      
115290          36.178     0.28
VertexStep(BOTH,edge)@[x]                                       20833868    
20833868        5203.088    40.90
EdgeOtherVertexStep                                             20833868    
20833868        7480.516    58.80
                                            >TOTAL                     -        
   -       12722.377        -
gremlin> g.V().bothE().otherV().bothE().as('x').otherV().profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           2.608     0.02
VertexStep(BOTH,vertex)                                           115290      
115290          36.527     0.29
VertexStep(BOTH,edge)@[x]                                       20833868    
20833868        5203.320    40.74
EdgeOtherVertexStep                                             20833868    
20833868        7531.105    58.96
                                            >TOTAL                     -        
   -       12773.562        -
gremlin> g.V().bothE().otherV().bothE().otherV().as('x').profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.586     0.73
VertexStep(BOTH,vertex)                                           115290      
115290          32.662    15.05
NoOpBarrierStep(2500)                                             115290       
13560          30.420    14.02
VertexStep(BOTH,vertex)@[x]                                     20833868      
507044         152.350    70.20
                                            >TOTAL                     -        
   -         217.020        -
gremlin> g.V().bothE().otherV().bothE().otherV().as('x').profile()
==>Traversal Metrics
Step                                                               Count  
Traversers       Time (ms)    % Dur
=============================================================================================================
TinkerGraphStep(vertex,[])                                          3749        
3749           1.378     0.62
VertexStep(BOTH,vertex)                                           115290      
115290          33.008    14.88
NoOpBarrierStep(2500)                                             115290       
13560          34.438    15.53
VertexStep(BOTH,vertex)@[x]                                     20833868      
507044         152.968    68.97
                                            >TOTAL                     -        
   -         221.793        -
gremlin> {code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to