

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

# OpenCypher 查询超时提示
<a name="opencypher-query-hints-timeout-hint"></a>

 可以通过查询级别的查询提示在每个查询的基础上配置查询超时行为。`QUERY:TIMEOUTMILLISECONDS`它必须与`USING`子句一起使用。查询提示接受非负长整数作为值。

------
#### [ AWS CLI ]

```
aws neptunedata execute-open-cypher-query \
  --endpoint-url https://your-neptune-endpoint:port \
  --open-cypher-query "USING QUERY:TIMEOUTMILLISECONDS 100 MATCH(n) RETURN n LIMIT 1"
```

有关更多信息，请参阅《 AWS CLI 命令参考》[execute-open-cypher-query](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/execute-open-cypher-query.html)中的。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://your-neptune-endpoint:port',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.execute_open_cypher_query(
    openCypherQuery='USING QUERY:TIMEOUTMILLISECONDS 100 MATCH(n) RETURN n LIMIT 1'
)

print(response['results'])
```

有关其他语言 AWS 的 SDK 示例，请参阅[AWS SDK](access-graph-opencypher-sdk.md)。

------
#### [ awscurl ]

```
awscurl https://your-neptune-endpoint:port/openCypher \
  --region us-east-1 \
  --service neptune-db \
  -X POST \
  -d "query=USING QUERY:TIMEOUTMILLISECONDS 100 MATCH(n) RETURN n LIMIT 1"
```

**注意**  
此示例假设您的 AWS 证书是在您的环境中配置的。*us-east-1*替换为 Neptune 集群的区域。

------
#### [ curl ]

```
curl https://your-neptune-endpoint:port/openCypher \
  -d "query=USING QUERY:TIMEOUTMILLISECONDS 100 MATCH(n) RETURN n LIMIT 1"
```

------

 查询超时行为将考虑集群级超时和查询级超时的最小值。请查看以下示例以了解查询超时行为。[有关集群级查询超时的更多信息，请参阅 neptune\$1query\$1timeout。](https://docs.aws.amazon.com/neptune/latest/userguide/parameters.html#parameters-db-cluster-parameters-neptune_query_timeout)

```
# Suppose `neptune_query_timeout` is 10000 ms and query-level timeout is set to 100 ms
# It will consider 100 ms as the final timeout 

curl https://your-neptune-endpoint:port/openCypher \
  -d "query=USING QUERY:TIMEOUTMILLISECONDS 100 MATCH(n) RETURN n LIMIT 1"

# Suppose `neptune_query_timeout` is 100 ms and query-level timeout is set to 10000 ms
# It will still consider 100 ms as the final timeout 

curl https://your-neptune-endpoint:port/openCypher \
  -d "query=USING QUERY:TIMEOUTMILLISECONDS 10000 MATCH(n) RETURN n LIMIT 1"
```

如果查询超过超时时间，Neptune 会将其终止并返回超时错误。是否重试超时查询取决于失败的性质和您的工作量。有关指南，请参阅[异常处理和重试](transactions-exceptions.md)。