Neptune の Gremlin profile API - Amazon Neptune

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

Neptune の Gremlin profile API

Neptune Gremlin profile API は、指定された Gremlin トラバーサルを実行し、実行に関するさまざまなメトリクスを収集して、出力として Profile レポートを生成します。

注記

この機能は、リリース 1.0.1.0.200463.0 (2019-10-15) で始めることで使用できます。

Neptune エンジンに固有の情報をレポートできるように、 TinkerPop .profile() ステップとは異なります。

Profile レポートには、クエリプランに関する次の情報が含まれます。

  • 物理演算子のパイプライン

  • クエリの実行とシリアル化のインデックスオペレーション

  • 結果のサイズ

profile API は、エンドポイントとして /gremlin の代わりに /gremlin/profile を使用して、クエリに HTTP API 構文の拡張バージョンを使用します。

Neptune Gremlin に固有のパラメータprofile

  • profile.resultsboolean、使用できる値:TRUE および FALSE、デフォルト値:TRUE

    true の場合、クエリ結果が収集され、profile レポートの一部として表示されます。false の場合、結果カウントのみが表示されます。

  • profile.chopint、デフォルト値:250。

    ゼロ以外の場合、結果の文字列はその文字数で切り捨てられます。これにより、すべての結果がキャプチャされなくなるわけではありません。Profile レポートの文字列のサイズを制限するだけです。ゼロに設定すると、文字列にはすべての結果が含まれます。

  • profile.serializerstring、デフォルト値: <null>

    null 以外の場合、収集された結果は、このパラメータで指定された形式でシリアル化されたレスポンスメッセージで返されます。そのレスポンスメッセージを生成するために必要なインデックスオペレーションの数は、クライアントに送信されるバイト単位のサイズとともにレポートされます。

    使用できる値は、 <null> または有効な MIME タイプまたは TinkerPop ドライバーの「シリアライザー」列挙値のいずれかです。

    "application/json" or "GRAPHSON" "application/vnd.gremlin-v1.0+json" or "GRAPHSON_V1" "application/vnd.gremlin-v1.0+json;types=false" or "GRAPHSON_V1_UNTYPED" "application/vnd.gremlin-v2.0+json" or "GRAPHSON_V2" "application/vnd.gremlin-v2.0+json;types=false" or "GRAPHSON_V2_UNTYPED" "application/vnd.gremlin-v3.0+json" or "GRAPHSON_V3" "application/vnd.gremlin-v3.0+json;types=false" or "GRAPHSON_V3_UNTYPED" "application/vnd.graphbinary-v1.0" or "GRAPHBINARY_V1"
  • profile.indexOpsboolean、使用できる値:TRUE および FALSE、デフォルト値:FALSE

    true の場合、クエリの実行およびシリアル化中に行われたすべてのインデックスオペレーションの詳細レポートが表示されます。警告: このレポートは冗長な場合があります。

Neptune Gremlin のサンプル出力profile

サンプル profile クエリを以下に示します。

curl -X POST https://your-neptune-endpoint:port/gremlin/profile \ -d '{"gremlin":"g.V().hasLabel(\"airport\") .has(\"code\", \"AUS\") .emit() .repeat(in().simplePath()) .times(2) .limit(100)", "profile.serializer":"application/vnd.gremlin-v3.0+gryo"}'

このクエリは、ブログ記事 Let Me Graph That For You – Part 1 – Air Routes からエアルートサンプルグラフで実行された場合、次の profile レポートを生成します。

******************************************************* Neptune Gremlin Profile ******************************************************* Query String ================== g.V().hasLabel("airport").has("code", "AUS").emit().repeat(in().simplePath()).times(2).limit(100) Original Traversal ================== [GraphStep(vertex,[]), HasStep([~label.eq(airport), code.eq(AUS)]), RepeatStep(emit(true),[VertexStep(IN,vertex), PathFilterStep(simple), RepeatEndStep],until(loops(2))), RangeGlobalStep(0,100)] Optimized Traversal =================== Neptune steps: [ NeptuneGraphQueryStep(Vertex) { JoinGroupNode { PatternNode[(?1, <code>, "AUS", ?) . project ?1 .], {estimatedCardinality=1, indexTime=84, hashJoin=true, joinTime=3, actualTotalOutput=1} PatternNode[(?1, <~label>, ?2=<airport>, <~>) . project ask .], {estimatedCardinality=3374, indexTime=29, hashJoin=true, joinTime=0, actualTotalOutput=61} RepeatNode { Repeat { PatternNode[(?3, ?5, ?1, ?6) . project ?1,?3 . IsEdgeIdFilter(?6) . SimplePathFilter(?1, ?3)) .], {hashJoin=true, estimatedCardinality=50148, indexTime=0, joinTime=3} } Emit { Filter(true) } LoopsCondition { LoopsFilter([?1, ?3],eq(2)) } }, annotations={repeatMode=BFS, emitFirst=true, untilFirst=false, leftVar=?1, rightVar=?3} }, finishers=[limit(100)], annotations={path=[Vertex(?1):GraphStep, Repeat[Vertex(?3):VertexStep]], joinStats=true, optimizationTime=495, maxVarId=7, executionTime=323} }, NeptuneTraverserConverterStep ] Physical Pipeline ================= NeptuneGraphQueryStep |-- StartOp |-- JoinGroupOp |-- SpoolerOp(100) |-- DynamicJoinOp(PatternNode[(?1, <code>, "AUS", ?) . project ?1 .], {estimatedCardinality=1, indexTime=84, hashJoin=true}) |-- SpoolerOp(100) |-- DynamicJoinOp(PatternNode[(?1, <~label>, ?2=<airport>, <~>) . project ask .], {estimatedCardinality=3374, indexTime=29, hashJoin=true}) |-- RepeatOp |-- <upstream input> (Iteration 0) [visited=1, output=1 (until=0, emit=1), next=1] |-- BindingSetQueue (Iteration 1) [visited=61, output=61 (until=0, emit=61), next=61] |-- SpoolerOp(100) |-- DynamicJoinOp(PatternNode[(?3, ?5, ?1, ?6) . project ?1,?3 . IsEdgeIdFilter(?6) . SimplePathFilter(?1, ?3)) .], {hashJoin=true, estimatedCardinality=50148, indexTime=0}) |-- BindingSetQueue (Iteration 2) [visited=38, output=38 (until=38, emit=0), next=0] |-- SpoolerOp(100) |-- DynamicJoinOp(PatternNode[(?3, ?5, ?1, ?6) . project ?1,?3 . IsEdgeIdFilter(?6) . SimplePathFilter(?1, ?3)) .], {hashJoin=true, estimatedCardinality=50148, indexTime=0}) |-- LimitOp(100) Runtime (ms) ============ Query Execution: 392.686 Serialization: 2636.380 Traversal Metrics ================= Step Count Traversers Time (ms) % Dur ------------------------------------------------------------------------------------------------------------- NeptuneGraphQueryStep(Vertex) 100 100 314.162 82.78 NeptuneTraverserConverterStep 100 100 65.333 17.22 >TOTAL - - 379.495 - Repeat Metrics ============== Iteration Visited Output Until Emit Next ------------------------------------------------------ 0 1 1 0 1 1 1 61 61 0 61 61 2 38 38 38 0 0 ------------------------------------------------------ 100 100 38 62 62 Predicates ========== # of predicates: 16 WARNING: reverse traversal with no edge label(s) - .in() / .both() may impact query performance Results ======= Count: 100 Output: [v[3], v[3600], v[3614], v[4], v[5], v[6], v[7], v[8], v[9], v[10], v[11], v[12], v[47], v[49], v[136], v[13], v[15], v[16], v[17], v[18], v[389], v[20], v[21], v[22], v[23], v[24], v[25], v[26], v[27], v[28], v[416], v[29], v[30], v[430], v[31], v[9... Response serializer: GRYO_V3D0 Response size (bytes): 23566 Index Operations ================ Query execution: # of statement index ops: 3 # of unique statement index ops: 3 Duplication ratio: 1.0 # of terms materialized: 0 Serialization: # of statement index ops: 200 # of unique statement index ops: 140 Duplication ratio: 1.43 # of terms materialized: 393

Neptune explain の呼び出しによって返されるクエリプランに加えて、profile の結果にはクエリ実行に関するランタイム統計が含まれます。各 Join オペレーションには、その結合の実行にかかった時間と、それを通過した実際のソリューションの数でタグが付けられます。

profile 出力には、コアクエリ実行フェーズでの所要時間と、profile.serializer オプションが指定されている場合にはシリアル化フェーズも含まれます。

各フェーズで実行されたインデックスオペレーションの内訳は、profile 出力の下部にも含まれます。

同じクエリを連続して実行すると、キャッシュのため、実行時とインデックスオペレーションに関して異なる結果が表示される場合があります。

repeat() ステップを使用したクエリの場合、repeat() ステップが NeptuneGraphQueryStep の一部としてプッシュダウンされた場合、各反復処理のフロンティアの内訳が利用可能です。

DFE が有効な時の profile レポートの違い

Neptune DFE 代替クエリエンジンが有効になっている場合、profile出力は多少異なります。

最適トラバーサル: このセクションは、explain 出力のセクションに似ていますが、追加情報が含まれています。これには、計画で考慮された DFE 演算子のタイプと、関連する最悪および最善のコスト見積もりが含まれます。

物理パイプライン: このセクションでは、クエリの実行に使用される演算子について説明します。DFESubQuery 要素は、DFE が担当するプランの一部を実行するために使用する物理プランを抽象化します。DFESubQuery 要素は次のセクションで展開され、DFE 統計情報が表示されます。

DFE QueryEngine 統計: このセクションは、クエリの少なくとも一部が DFE によって実行された場合にのみ表示されます。DFE に固有の各種ランタイム統計を概説し、DFESubQuery による、クエリ実行のさまざまな部分に費やされた時間の詳細な内訳を以下に示します。

別の DFESubQuery 要素にネストされたサブクエリは、このセクションでフラット化され、一意の識別子に subQuery= で始まるヘッダーが付けられます。

トラバーサルメトリクス: このセクションには、ステップレベルのトラバーサルメトリックが表示され、DFE エンジンがクエリの全部または一部を実行すると、DFEStepおよび/またはNeptuneInterleavingStepのメトリクスが表示されます。explainおよびprofileを使用した Gremlin クエリのチューニング を参照してください。

注記

DFE はラボモードでリリースされる実験的な機能なので、profile 出力はまだ変更される可能性があります。

Neptune データフローエンジン (DFE) が有効な場合のサンプルprofile 出力

DFE エンジンが Gremlin クエリの実行に使用されている場合、Gremlin profile API の出力は、次の例に示すようにフォーマットされます。

クエリ:

curl https://localhost:8182/gremlin/profile \ -d "{\"gremlin\": \"g.withSideEffect('Neptune#useDFE', true).V().has('code', 'ATL').out()\"}"
******************************************************* Neptune Gremlin Profile ******************************************************* Query String ================== g.withSideEffect('Neptune#useDFE', true).V().has('code', 'ATL').out() Original Traversal ================== [GraphStep(vertex,[]), HasStep([code.eq(ATL)]), VertexStep(OUT,vertex)] Optimized Traversal =================== Neptune steps: [ DFEStep(Vertex) { DFENode { DFEJoinGroupNode[null]( children=[ DFEPatternNode((?1, vp://code[419430926], ?4, defaultGraph[526]) . project DISTINCT[?1] objectFilters=(in(ATL[452987149]) . ), {rangeCountEstimate=1}, opInfo=(type=PipelineJoin, cost=(exp=(in=1.00,out=1.00,io=0.00,comp=0.00,mem=0.00),wc=(in=1.00,out=1.00,io=0.00,comp=0.00,mem=0.00)), disc=(type=PipelineScan, cost=(exp=(in=1.00,out=1.00,io=0.00,comp=0.00,mem=34.00),wc=(in=1.00,out=1.00,io=0.00,comp=0.00,mem=34.00))))), DFEPatternNode((?1, ?5, ?6, ?7) . project ALL[?1, ?6] graphFilters=(!= defaultGraph[526] . ), {rangeCountEstimate=9223372036854775807})], opInfo=[ OperatorInfoWithAlternative[ rec=(type=PipelineJoin, cost=(exp=(in=1.00,out=27.76,io=0.00,comp=0.00,mem=0.00),wc=(in=1.00,out=27.76,io=0.00,comp=0.00,mem=0.00)), disc=(type=PipelineScan, cost=(exp=(in=1.00,out=27.76,io=Infinity,comp=0.00,mem=295147905179352830000.00),wc=(in=1.00,out=27.76,io=Infinity,comp=0.00,mem=295147905179352830000.00)))), alt=(type=PipelineScan, cost=(exp=(in=1.00,out=27.76,io=Infinity,comp=0.00,mem=295147905179352830000.00),wc=(in=1.00,out=27.76,io=Infinity,comp=0.00,mem=295147905179352830000.00)))]]) } [Vertex(?1):GraphStep, Vertex(?6):VertexStep] } , NeptuneTraverserConverterDFEStep, DFECleanupStep ] Physical Pipeline ================= DFEStep |-- DFESubQuery1 DFEQueryEngine Statistics ================= DFESubQuery1 ╔════╤════════╤════════╤═══════════════════════╤══════════════════════════════════════════════════════════════════════════════════════════════════════════════╤══════╤══════════╤═══════════╤════════╤═══════════╗ ║ ID │ Out #1 │ Out #2 │ Name │ Arguments │ Mode │ Units In │ Units Out │ Ratio │ Time (ms) ║ ╠════╪════════╪════════╪═══════════════════════╪══════════════════════════════════════════════════════════════════════════════════════════════════════════════╪══════╪══════════╪═══════════╪════════╪═══════════╣ ║ 0 │ 1 │ - │ DFESolutionInjection │ solutions=[] │ - │ 0 │ 1 │ 0.00 │ 0.01 ║ ║ │ │ │ │ outSchema=[] │ │ │ │ │ ║ ╟────┼────────┼────────┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 1 │ 2 │ - │ DFEChunkLocalSubQuery │ subQuery=http://aws.amazon.com/neptune/vocab/v01/dfe/past/graph#089f43e3-4d71-4259-8d19-254ff63cee04/graph_1 │ - │ 1 │ 1 │ 1.00 │ 0.02 ║ ╟────┼────────┼────────┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 2 │ 3 │ - │ DFEChunkLocalSubQuery │ subQuery=http://aws.amazon.com/neptune/vocab/v01/dfe/past/graph#089f43e3-4d71-4259-8d19-254ff63cee04/graph_2 │ - │ 1 │ 242 │ 242.00 │ 0.02 ║ ╟────┼────────┼────────┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 3 │ 4 │ - │ DFEMergeChunks │ - │ - │ 242 │ 242 │ 1.00 │ 0.01 ║ ╟────┼────────┼────────┼───────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 4 │ - │ - │ DFEDrain │ - │ - │ 242 │ 0 │ 0.00 │ 0.01 ║ ╚════╧════════╧════════╧═══════════════════════╧══════════════════════════════════════════════════════════════════════════════════════════════════════════════╧══════╧══════════╧═══════════╧════════╧═══════════╝ subQuery=http://aws.amazon.com/neptune/vocab/v01/dfe/past/graph#089f43e3-4d71-4259-8d19-254ff63cee04/graph_1 ╔════╤════════╤════════╤══════════════════════╤═════════════════════════════════════════════════════════════╤══════╤══════════╤═══════════╤═══════╤═══════════╗ ║ ID │ Out #1 │ Out #2 │ Name │ Arguments │ Mode │ Units In │ Units Out │ Ratio │ Time (ms) ║ ╠════╪════════╪════════╪══════════════════════╪═════════════════════════════════════════════════════════════╪══════╪══════════╪═══════════╪═══════╪═══════════╣ ║ 0 │ 1 │ - │ DFEPipelineScan │ pattern=Node(?1) with property 'code' as ?4 and label 'ALL' │ - │ 0 │ 1 │ 0.00 │ 0.22 ║ ║ │ │ │ │ inlineFilters=[(?4 IN ["ATL"])] │ │ │ │ │ ║ ║ │ │ │ │ patternEstimate=1 │ │ │ │ │ ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼───────┼───────────╢ ║ 1 │ 2 │ - │ DFEMergeChunks │ - │ - │ 1 │ 1 │ 1.00 │ 0.02 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼───────┼───────────╢ ║ 2 │ 4 │ - │ DFERelationalJoin │ joinVars=[] │ - │ 2 │ 1 │ 0.50 │ 0.09 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼───────┼───────────╢ ║ 3 │ 2 │ - │ DFESolutionInjection │ solutions=[] │ - │ 0 │ 1 │ 0.00 │ 0.01 ║ ║ │ │ │ │ outSchema=[] │ │ │ │ │ ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────────────────────────────┼──────┼──────────┼───────────┼───────┼───────────╢ ║ 4 │ - │ - │ DFEDrain │ - │ - │ 1 │ 0 │ 0.00 │ 0.01 ║ ╚════╧════════╧════════╧══════════════════════╧═════════════════════════════════════════════════════════════╧══════╧══════════╧═══════════╧═══════╧═══════════╝ subQuery=http://aws.amazon.com/neptune/vocab/v01/dfe/past/graph#089f43e3-4d71-4259-8d19-254ff63cee04/graph_2 ╔════╤════════╤════════╤══════════════════════╤═════════════════════════════════════╤══════╤══════════╤═══════════╤════════╤═══════════╗ ║ ID │ Out #1 │ Out #2 │ Name │ Arguments │ Mode │ Units In │ Units Out │ Ratio │ Time (ms) ║ ╠════╪════════╪════════╪══════════════════════╪═════════════════════════════════════╪══════╪══════════╪═══════════╪════════╪═══════════╣ ║ 0 │ 1 │ - │ DFESolutionInjection │ solutions=[] │ - │ 0 │ 1 │ 0.00 │ 0.01 ║ ║ │ │ │ │ outSchema=[?1] │ │ │ │ │ ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 1 │ 2 │ 3 │ DFETee │ - │ - │ 1 │ 2 │ 2.00 │ 0.01 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 2 │ 4 │ - │ DFEDistinctColumn │ column=?1 │ - │ 1 │ 1 │ 1.00 │ 0.21 ║ ║ │ │ │ │ ordered=false │ │ │ │ │ ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 3 │ 5 │ - │ DFEHashIndexBuild │ vars=[?1] │ - │ 1 │ 1 │ 1.00 │ 0.03 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 4 │ 5 │ - │ DFEPipelineJoin │ pattern=Edge((?1)-[?7:?5]->(?6)) │ - │ 1 │ 242 │ 242.00 │ 0.51 ║ ║ │ │ │ │ constraints=[] │ │ │ │ │ ║ ║ │ │ │ │ patternEstimate=9223372036854775807 │ │ │ │ │ ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 5 │ 6 │ 7 │ DFESync │ - │ - │ 243 │ 243 │ 1.00 │ 0.02 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 6 │ 8 │ - │ DFEForwardValue │ - │ - │ 1 │ 1 │ 1.00 │ 0.01 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 7 │ 8 │ - │ DFEForwardValue │ - │ - │ 242 │ 242 │ 1.00 │ 0.02 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 8 │ 9 │ - │ DFEHashIndexJoin │ - │ - │ 243 │ 242 │ 1.00 │ 0.31 ║ ╟────┼────────┼────────┼──────────────────────┼─────────────────────────────────────┼──────┼──────────┼───────────┼────────┼───────────╢ ║ 9 │ - │ - │ DFEDrain │ - │ - │ 242 │ 0 │ 0.00 │ 0.01 ║ ╚════╧════════╧════════╧══════════════════════╧═════════════════════════════════════╧══════╧══════════╧═══════════╧════════╧═══════════╝ Runtime (ms) ============ Query Execution: 11.744 Traversal Metrics ================= Step Count Traversers Time (ms) % Dur ------------------------------------------------------------------------------------------------------------- DFEStep(Vertex) 242 242 10.849 95.48 NeptuneTraverserConverterDFEStep 242 242 0.514 4.52 >TOTAL - - 11.363 - Predicates ========== # of predicates: 18 Results ======= Count: 242 Index Operations ================ Query execution: # of statement index ops: 0 # of terms materialized: 0
注記

DFE エンジンはラボモードでリリースされる実験的な機能なので、profile 出力は変更される可能性があります。