版本

# 查询语言


# 简介

eZooDB支持Cypher,支持query的语句查询和explain的执行计划输出。

Cypher是用于图数据库的最广泛采用、完全指定和开放的查询语言, 并属于声明性图形查询语言。它允许对图形进行富有表现力和高效的查询、更新和管理并提供了一种使用属性图的直观方式。

更多图查询语言相关的内容,可参阅opencypher (opens new window)


# 版本

Cypher查询语言参考(第 9 版)


# API

eZooDB对于使用者提供了统一的API接口,返回结果为结构体,如果需要使用特定的格式输出,可以选择自定义,或使用eZoo-Client。

# 方法

void QL(client_result &_return, 
        const std::string &db_name, 
        const std::string &query)

# 参数

参数列表 类型 描述 是否可空 默认值 示例 备注
db_name string 数据库名称 "" "ezoo"
query string cypher语句 * ""

# 返回值

参数列表 类型 描述 是否可空 默认值 示例 备注
_return client_result 查询结果返回

# 数据类型

eZooDB Cypher支持整数、浮点、字符串、布尔值等基本数据类型,如下所示:

分类 类型 支持情况
Property types Number / String / Boolean / Spatial / Temporal 暂不支持 Spatial / Temporal
Structural types Node / Relationship / Path 支持
Composite types List / Map map作为返回值时暂不支持

# 子句

关键字 支持情况
MATCH 支持
OPTIONAL MATCH 支持
RETURN 支持
WITH 支持
UNWIND 支持
WHERE 支持
ORDER BY 支持
SKIP 支持
LIMIT 支持
CREATE 暂不支持
DELETE 暂不支持
SET 暂不支持
REMOVE 暂不支持
FOREACH 暂不支持
MERGE 暂不支持
CALL {subquery} 暂不支持
CALL procedure 暂不支持
UNION 暂不支持
USE 暂不支持
LOAD CSV 暂不支持

# 内置函数

函数名称 分类 支持情况
all() Predicate 支持
any() Predicate 支持
single() Predicate 支持
none() Predicate 支持
list_comprehension() Predicate 支持
exists() Predicate 支持
coalesce() Scalar 支持
case() Scalar 支持
endNode() Scalar 支持
head() Scalar 支持
id() Scalar 支持
last() Scalar 暂不支持
length() Scalar 暂不支持
properties() Scalar 支持
randomUUID() Scalar 暂不支持
size() Scalar 支持
Size of pattern comprehension Scalar 暂不支持
Size of string Scalar 支持
startNode() Scalar 支持
timestamp() Scalar 暂不支持
toBoolean() Scalar 暂不支持
toBooleanOrNull() Scalar 暂不支持
toFloat() Scalar 暂不支持
toFloatOrNull() Scalar 暂不支持
toInteger() Scalar 支持
toIntegerOrNull() Scalar 暂不支持
type() Scalar 支持
avg() - Numeric values Aggregating 支持
avg() - Durations Aggregating 暂不支持
collect() Aggregating 支持
count() Aggregating 支持
max() Aggregating 支持
min() Aggregating 支持
percentileCont() Aggregating 支持
percentileDisc() Aggregating 支持
stDev() Aggregating 支持
stDevP() Aggregating 支持
sum() - Numeric values Aggregating 支持
sum() - Durations Aggregating 暂不支持
keys() List 暂不支持
labels() List 支持
nodes() List 支持
range() List 支持
reduce() List 支持
relationships() List 支持
reverse() List 支持
tail() List 支持
toBooleanList() List 暂不支持
toFloatList() List 暂不支持
toIntegerList() List 暂不支持
toStringList() List 暂不支持
abs() Numeric 支持
ceil() Numeric 支持
floor Numeric 支持
rand() Numeric 支持
round() Numeric 支持
round()- precision Numeric 暂不支持
round() - precision and rounding mode Numeric 暂不支持
sign() Numeric 支持
e() Logarithmic 暂不支持
exp() Logarithmic 暂不支持
log() Logarithmic 暂不支持
log10() Logarithmic 暂不支持
sqrt() Logarithmic 支持
acos() Trigonometric 暂不支持
asin() Trigonometric 暂不支持
atan() Trigonometric 暂不支持
atan2() Trigonometric 暂不支持
cos() Trigonometric 暂不支持
cot() Trigonometric 暂不支持
degrees() Trigonometric 暂不支持
haversin() Trigonometric 暂不支持
pi() Trigonometric 暂不支持
radians() Trigonometric 暂不支持
sin() Trigonometric 暂不支持
tan() Trigonometric 暂不支持
left() String 支持
lTrim() String 支持
replace() String 支持
reverse() String 支持
right() String 支持
rTrim() String 支持
split() String 暂不支持
substring() String 支持
toLower() String 支持
toString() String 支持
toStringOrNull() String 暂不支持
toUpper() String 支持
trim() String 支持
date() Temporal 暂不支持
datetime() Temporal 暂不支持
localdatetime() Temporal 暂不支持
localtime() Temporal 暂不支持
time() Temporal 暂不支持
point() Spatial 暂不支持
point.distance() Spatial 暂不支持
point.withinBBox() Spatial 暂不支持
linenumber() LOAD CSV 暂不支持
file() LOAD CSV 暂不支持

# 查询调优

eZooDB旨在以最快的速度查询出正确的结果,每一个cypher查询都会通过优化生成最优执行计划,以减少不必要的查询。

在eZooDB中cypher语句的重复查询是被允许的,内部做了cypher语句的缓存工作,以cypher语句为key,执行计划为value,以减少重复解析和构建新的执行计划的过程。


# 分析查询

当您想通过查看查询的执行计划来分析查询时,可以使用以下方法:

# EXPLAIN:

如果您想查看执行计划,但不想运行语句,请在Cypher语句之前使用EXPLAIN。该语句将始终返回一个空结果,并且不会对数据库进行更改。

例如:

graph_500> EXPLAIN MATCH (A)-[C]->(B) RETURN A
最近一次更新时间: 9/15/2022, 3:02:34 AM