知识库

如何通过 cypher-shell 和管道查询文件生成 profile/explain

如果您准备了一个包含 `profile` 或 `explain` 子句的 Cypher 语句文件,然后希望将其通过管道传递给 bin/cypher-shell,为了生成 profile/explain 输出,您必须在命令行中包含 `--format verbose`。

例如,当您的文件 mycypher.cql 包含以下内容时:

profile match (n:Movies) return count(n);

如果您运行以下命令:

$ cat mycypher.cql | ./cypher-shell

输出将是:

Plan: "PROFILE"
Statement: "READ_ONLY"
Version: "CYPHER 3.2"
Planner: "COST"
Runtime: "COMPILED"
Time: 42
DbHits: 0
Rows: 1
count(n)
0

但是,当运行以下命令时:

$ cat mycypher.cql | ./cypher-shell --format verbose

输出将变为:

+--------------------------------------------------------------------------------------+
| Plan      | Statement   | Version      | Planner | Runtime    | Time | DbHits | Rows |
+--------------------------------------------------------------------------------------+
| "PROFILE" | "READ_ONLY" | "CYPHER 3.2" | "COST"  | "COMPILED" | 0    | 0      | 1    |
+--------------------------------------------------------------------------------------+

+--------------------------+----------------+------+---------+-----------+-----------+-------------+---------------------------------------+
| Operator                 | Estimated Rows | Rows | DB Hits | Cache H/M | Time (ms) | Identifiers | Other                                 |
+--------------------------+----------------+------+---------+-----------+-----------+-------------+---------------------------------------+
| +ProduceResults          |              1 |    1 |       0 |       0/0 |     0.019 | count(n)    | 19237                                 |
| |                        +----------------+------+---------+-----------+-----------+-------------+---------------------------------------+
| +NodeCountFromCountStore |              1 |    0 |       1 |       0/0 |     0.029 | count(n)    | 29320; count( (:Movies) ) AS count(n) |
+--------------------------+----------------+------+---------+-----------+-----------+-------------+---------------------------------------+

+----------+
| count(n) |
+----------+
| 0        |
+----------+