

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 搭配 Neptune DFE 查詢引擎使用 Gremlin
<a name="gremlin-with-dfe"></a>

如果您啟用稱為 DFE 的 Neptune [替代查詢引擎](neptune-dfe-engine.md) （透過將[neptune\_dfe\_query\_engine](parameters.md#parameters-instance-parameters-neptune_dfe_query_engine)執行個體參數設定為 `enabled`)，則 Neptune 會將唯讀 Gremlin 查詢/周遊轉譯為中繼邏輯表示法，並盡可能在 DFE 引擎上執行它們。

不過，DFE 尚未支援所有的 Gremlin 步驟。當步驟無法在 DFE 上以原生方式執行時，Neptune 會退回至 TinkerPop 以執行該步驟。`explain` 和 `profile` 報告包含此情況發生時的警告。

## 查詢規劃交錯
<a name="gremlin-with-dfe-interleaving"></a>

當轉換程序遇到沒有對應的原生 DFE 運算子的 Gremlin 步驟時，在退回使用 Tinkerpop 之前，它會嘗試尋找其他可以在 DFE 引擎上以原生方式執行的中繼查詢組件。它透過將交錯邏輯應用到頂層周遊來執行此操作。結果是盡可能使用支援的步驟。

任何此類中繼、非字首查詢轉換都會在 `explain` 和 `profile` 輸出中使用 `NeptuneInterleavingStep` 來表示。

為了進行效能比較，您可能想要關閉查詢中的交錯，同時仍使用 DFE 引擎來執行字首部分。或者，您可能只想要使用 TinkerPop 引擎，進行非字首查詢執行。您可以使用 `disableInterleaving` 查詢提示來做到這一點。

正如值為 `false` 的 [useDFE](gremlin-query-hints-useDFE.md) 查詢提示可防止完全不能在 DFE 上執行查詢一樣，值為 `true` 的 `disableInterleaving` 查詢提示會關閉 DFE 交錯以進行查詢轉換。例如：

```
g.with('Neptune#disableInterleaving', true)
 .V().has('genre','drama').in('likes')
```

## 已更新 Gremlin `explain` 和 `profile` 輸出
<a name="gremlin-with-dfe-explain-update"></a>

Gemlin [explain](gremlin-explain.md) 會提供有關 Neptune 用來執行查詢的最佳化周遊的詳細資訊。請參閱[範例 DFE `explain` 輸出](gremlin-explain-api.md#gremlin-explain-dfe)，以取得 DFE 引擎啟用時 `explain` 輸出的外觀範例。

[Gremlin `profile` API](gremlin-profile-api.md) 會執行指定的 Gemlin 周遊、收集有關執行的各種指標，以及產生設定檔報告，其中包含有關最佳化的查詢計畫和各種運算子的執行期統計資料的詳細資訊。請參閱[範例 DFE `profile` 輸出](gremlin-profile-api.md#gremlin-profile-sample-dfe-output)，以取得 DFE 引擎啟用時 `profile` 輸出的外觀範例。

**注意**  
由於 Gremlin 的 DFE 支援是一項實驗性功能，因此 `explain`和 `profile`輸出的確切格式可能會有所變更。