View a markdown version of this page

openCypher 查询计划缓存提示 - Amazon Neptune

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

openCypher 查询计划缓存提示

查询级别的查询提示 QUERY:PLANCACHE 可以在每个查询(无论是否参数化)的基础上覆盖查询计划缓存行为。它需要与 USING 子句一起使用。该查询提示接受 enableddisabled 作为值。有关查询计划缓存的更多信息,请参阅 Amazon Neptune 中的查询计划缓存

AWS CLI

强制对计划进行缓存或重复使用:

aws neptunedata execute-open-cypher-query \ --endpoint-url https://your-neptune-endpoint:port \ --open-cypher-query "Using QUERY:PLANCACHE \"enabled\" MATCH(n) RETURN n LIMIT 1"

参数为:

aws neptunedata execute-open-cypher-query \ --endpoint-url https://your-neptune-endpoint:port \ --open-cypher-query "Using QUERY:PLANCACHE \"enabled\" RETURN \$arg" \ --parameters '{"arg": 123}'

强制既不缓存也不重复使用计划:

aws neptunedata execute-open-cypher-query \ --endpoint-url https://your-neptune-endpoint:port \ --open-cypher-query "Using QUERY:PLANCACHE \"disabled\" 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}) ) # Forcing plan to be cached or reused response = client.execute_open_cypher_query( openCypherQuery='Using QUERY:PLANCACHE "enabled" MATCH(n) RETURN n LIMIT 1' ) print(response['results'])

有关其他语言 AWS 的 SDK 示例,请参阅AWS SDK

awscurl

强制对计划进行缓存或重复使用:

awscurl https://your-neptune-endpoint:port/openCypher \ --region us-east-1 \ --service neptune-db \ -X POST \ -d "query=Using QUERY:PLANCACHE \"enabled\" MATCH(n) RETURN n LIMIT 1"
注意

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

curl

强制对计划进行缓存或重复使用:

curl https://your-neptune-endpoint:port/openCypher \ -d "query=Using QUERY:PLANCACHE \"enabled\" MATCH(n) RETURN n LIMIT 1"

参数为:

curl https://your-neptune-endpoint:port/openCypher \ -d "query=Using QUERY:PLANCACHE \"enabled\" RETURN \$arg" \ -d "parameters={\"arg\": 123}"

强制既不缓存也不重复使用计划:

curl https://your-neptune-endpoint:port/openCypher \ -d "query=Using QUERY:PLANCACHE \"disabled\" MATCH(n) RETURN n LIMIT 1"