

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 在 Neptune DFE 查询引擎中使用 Gremlin
<a name="gremlin-with-dfe"></a>

如果您启用 Neptune 的[替代查询引擎](neptune-dfe-engine.md)，即 DFE（通过将[neptune\$1dfe\$1query\$1engine](parameters.md#parameters-instance-parameters-neptune_dfe_query_engine)实例参数设置为`enabled`），那么 Neptune 会将只读 Gremlin queries/traversals 转换为中间逻辑表示形式，并尽可能在 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>

Gremlin [explain](gremlin-explain.md) 提供有关 Neptune 用来运行查询的优化遍历的详细信息。有关启用 DFE 引擎时 `explain` 输出内容的示例，请参阅 [DFE `explain` 输出示例](gremlin-explain-api.md#gremlin-explain-dfe)。

[Gremlin `profile` API](gremlin-profile-api.md) 运行指定的 Gremlin 遍历，收集有关运行的各种指标，并生成 Profile 报告，其中包含有关优化查询计划的详细信息以及各种运算符的运行时系统统计数据。有关启用 DFE 引擎时 `profile` 输出内容的示例，请参阅 [DFE `profile` 输出示例](gremlin-profile-api.md#gremlin-profile-sample-dfe-output)。

**注意**  
由于 DFE 对 Gremlin 的支持是一项实验性功能，因此`explain`和`profile`输出的确切格式可能会发生变化。