From 39969556fce1bc77ce982f3bf54a1abe7771695e Mon Sep 17 00:00:00 2001 From: Prashanth Rao <35005448+prrao87@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:36:28 -0500 Subject: [PATCH] Add docs for CLI and WHERE clause (#322) * Fix #312 * Fix #311 --- src/content/docs/client-apis/cli.mdx | 19 ++++++-- .../docs/cypher/query-clauses/where.md | 48 ++++++++++++++----- 2 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/content/docs/client-apis/cli.mdx b/src/content/docs/client-apis/cli.mdx index 8d2d8509..2e87b38b 100644 --- a/src/content/docs/client-apis/cli.mdx +++ b/src/content/docs/client-apis/cli.mdx @@ -40,15 +40,14 @@ Opened the database under in-memory mode. Enter ":help" for usage hints. kuzu> ``` - ## Shell commands Once you start the shell, you can issue Cypher queries as shown in the [get started](/get-started) section. List all available shell commands by running `./kuzu -h`. ```bash -$ ./kuzu -h - ./kuzu [databasePath] {OPTIONS} +$ kuzu -h + kuzu [databasePath] {OPTIONS} KuzuDB Shell @@ -69,6 +68,20 @@ $ ./kuzu -h arguments to be treated as positional options ``` +:::caution[Note on memory usage] +By default, Kùzu's CLI is launched with a maximum buffer pool size of 80% of the available memory. +If you want to launch the Kùzu CLI with a different buffer pool size, you can do so by setting the +`--defaultbpsize` or `-d` flag to the desired value in megabytes. +::: + + +To limit the buffer pool size to use just 4GB of memory, you can use the following command: + +```bash +kuzu --defaultbpsize 4096 +``` + + #### `:help` Show built-in command list within the Kùzu shell. diff --git a/src/content/docs/cypher/query-clauses/where.md b/src/content/docs/cypher/query-clauses/where.md index 8d7344c7..5d7a5685 100644 --- a/src/content/docs/cypher/query-clauses/where.md +++ b/src/content/docs/cypher/query-clauses/where.md @@ -21,13 +21,13 @@ RETURN *; ``` Output: ``` ---------------------------------------------- -| a | ---------------------------------------------- -| (label:User, 0:1, {name:Karissa, age:40}) | ---------------------------------------------- -| (label:User, 0:2, {name:Zhang, age:50}) | ---------------------------------------------- +┌──────────────────────────────────────────────────┐ +│ a │ +│ NODE │ +├──────────────────────────────────────────────────┤ +│ {_ID: 0:1, _LABEL: User, name: Karissa, age: 40} │ +│ {_ID: 0:2, _LABEL: User, name: Zhang, age: 50} │ +└──────────────────────────────────────────────────┘ ``` The boolean predicate specified above can be understood as it reads: Users "a" whose ages are @@ -44,9 +44,33 @@ RETURN *; ``` Output: ``` ---------------------------------------------- -| a | ---------------------------------------------- -| (label:User, 0:1, {name:Karissa, age:40}) | ---------------------------------------------- +┌──────────────────────────────────────────────────┐ +│ a │ +│ NODE │ +├──────────────────────────────────────────────────┤ +│ {_ID: 0:1, _LABEL: User, name: Karissa, age: 40} │ +└──────────────────────────────────────────────────┘ ``` + +## `WHERE` subquery on a relationship + +You can also specify a subquery that matches a relationship using the `WHERE` clause. + +```cypher +MATCH (a:User) +WHERE (a)-[r1:Follows]->(b:User {name: "Noura"})-[r2:LivesIn]->(c:City {name: "Guelph"}) +RETURN a; +``` +``` +┌────────────────────────────────────────────────┐ +│ a │ +│ NODE │ +├────────────────────────────────────────────────┤ +│ {_ID: 0:2, _LABEL: User, name: Zhang, age: 50} │ +└────────────────────────────────────────────────┘ +``` + +The above query matches users who follow "Noura" and lives in "Guelph". Note that you can only +`RETURN` the nodes that are in the scope of the `MATCH` clause (the nodes and relationships that +are in the `WHERE` clause are not returned). +