View a markdown version of this page

openCypher 查詢逾時提示 - Amazon Neptune

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

openCypher 查詢逾時提示

查詢逾時行為可以透過查詢層級查詢提示 依每個查詢進行設定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

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 開發套件

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_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 會終止它並傳回逾時錯誤。是否重試逾時查詢取決於失敗的性質和工作負載。如需準則,請參閱例外狀況處理和重試