AssumeConsistentDataTypes ヒント - Amazon Neptune

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

AssumeConsistentDataTypes ヒント

openCypher は、数値データ型 (int、byte、short、long など) の一致がタイプの昇格セマンティクスで実行されるパラダイムに従います。例えば、入力値 10 のプロパティをタイプが短いすべてのプロパティで検索する場合、タイプ昇格セマンティクスでは、10 のプロパティも長い値として一致します。場合によっては、型キャストによってオーバーヘッドが発生し、型キャストが実行されなかった場合よりも効率の低いクエリプランが発生することがあります。特に、データ型がデータで一貫して使用されている場合 (例: すべての人の年齢が長い値として保存されている場合)、タイププロモーションを実行すると、クエリ結果に影響を与えずにオーバーヘッドが発生します。

データベースに保存されている数値プロパティデータ値が整合性のある型であることがわかっている場合に最適化を可能にするために、 assumeConsistentDataTypes というクエリヒント (値 でtrue/false、デフォルトは false) を使用できます。このクエリヒントに の値を指定するとtrue、エンジンはプロパティ値のみが常に長または倍長であると見なし、タイプ昇格セマンティクスをスキップします。クエリで指定された数値は、長い値 (浮動小数点値以外) と二重値 (浮動小数点値) のいずれかと見なされます。

データが 1 つのデータ型を一貫して使用している場合 (たとえば、すべての経過時間が として保存されている場合long)、assumeConsistentDataTypesヒントを使用すると、異なる数値型の不要な等価チェックをスキップしてクエリを最適化できます。ただし、同じプロパティのデータ型に一貫性がない場合、ヒントを使用すると、クエリはヒントが想定する単一のデータ型にのみ一致するため、結果の一部が失われる可能性があります。

# Database loaded with following openCypher CSV's # File 1 :ID,age:Int n1,20 n2,25 # File 2 :ID,age:Long n3,25 # Example (no hint) MATCH (n:Person) WHERE n.age >= 25 RETURN n # Result n2 n3 Returns all person whose age is >= 25 and the values >= 25 can be with any of these datatypes i.e. byte, short, int, long, double or float ----------------------------------------------------------------------------------- # Example (with hint present) USING QUERY:assumeConsistentDataTypes "true" MATCH (n:Person) WHERE n.age >= 25 RETURN n # Result n3 Returns only "n3" and not "n2". The reason is that even though the numerical value matches (25), the datatype is "int" and is considered a non-match.

この違いは、説明を通じて検証することもできます。

説明なしの場合:

# Query MATCH (n) WHERE n.age = 20 RETURN n # Explain Snippet ╔═════╤══════════╤══════════╤══════════════════════════════╤═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╤════════╤════════════╤══════════════╤═════════╤══════════════╗ ║ ID │ Out #1 │ Out #2 │ Name │ Arguments │ Mode │ Units In │ Units Out │ Ratio │ Time (ms) ║ ╠═════╪══════════╪══════════╪══════════════════════════════╪═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╪════════╪════════════╪══════════════╪═════════╪══════════════╣ ║ 0 │ 1 │ - │ DFEPipelineScan (DFX) │ pattern=Node(?n) with property 'age' as ?n_age2 and label 'ALL' │ - │ 0 │ 1 │ 0.00 │ 0.10 ║ ║ │ │ │ │ inlineFilters=[(?n_age2 IN ["20"^^xsd:byte, "20"^^xsd:int, "20"^^xsd:long, "20"^^xsd:short, "20.0"^^xsd:double, "20.0"^^xsd:float])] │ │ │ │ │ ║ ║ │ │ │ │ patternEstimate=1 │ │ │ │ │ ║ ╟─────┼──────────┼──────────┼──────────────────────────────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────┼────────────┼──────────────┼─────────┼──────────────╢ # The inFilters field contains all numeric types

ヒントを使用して:

# Query MATCH (n) WHERE n.age = 20 RETURN n # Explain Snippet ╔═════╤══════════╤══════════╤══════════════════════════════╤═════════════════════════════════════════════════════════════════════════════════╤════════╤════════════╤══════════════╤═════════╤══════════════╗ ║ ID │ Out #1 │ Out #2 │ Name │ Arguments │ Mode │ Units In │ Units Out │ Ratio │ Time (ms) ║ ╠═════╪══════════╪══════════╪══════════════════════════════╪═════════════════════════════════════════════════════════════════════════════════╪════════╪════════════╪══════════════╪═════════╪══════════════╣ ║ 0 │ 1 │ - │ DFEPipelineScan (DFX) │ pattern=Node(?n) with property 'age' as ?n_age2 and label 'ALL' │ - │ 0 │ 1 │ 0.00 │ 0.07 ║ ║ │ │ │ │ inlineFilters=[(?n_age2 IN ["20"^^xsd:long])] │ │ │ │ │ ║ ║ │ │ │ │ patternEstimate=1 │ │ │ │ │ ║ ╟─────┼──────────┼──────────┼──────────────────────────────┼─────────────────────────────────────────────────────────────────────────────────┼────────┼────────────┼──────────────┼─────────┼──────────────╢ # The inFilters field only contains long datatype