From e09c00cb26b200eda88aff97a7c3715db396484b Mon Sep 17 00:00:00 2001 From: AlexicaWright <49636617+AlexicaWright@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:10:07 +0100 Subject: [PATCH 1/4] add query for counting databases in a cluster --- .../standard-databases/manage-databases.adoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc index 8d5b83fee..8afb9a80f 100644 --- a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc +++ b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc @@ -319,6 +319,18 @@ RETURN count(*) AS count +-------+ ---- +In a cluster, the `SHOW DATABASES` returns the number of allocations of databases and may be misleading if the number of distinct databases is desired. +In this case, the number of distinct databases hosted in a cluster can be seen using a `count()` aggregation with `YIELD` and `RETURN` with `name` instead of the wildcard. + +.Query +[source, cypher] +---- +SHOW DATABASES YIELD name +RETURN count(DISTINCT name) AS count +---- + + + === Show the default database The default database can be seen using the command `SHOW DEFAULT DATABASE`. From ea520dc4347471014aea00c6aeba02a5ba418584 Mon Sep 17 00:00:00 2001 From: Jessica Wright <49636617+AlexicaWright@users.noreply.github.com> Date: Mon, 4 Dec 2023 09:18:07 +0100 Subject: [PATCH 2/4] Update modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jens Pryce-Ã…klundh <112686610+JPryce-Aklundh@users.noreply.github.com> --- .../standard-databases/manage-databases.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc index 8afb9a80f..399c7dd3e 100644 --- a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc +++ b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc @@ -320,7 +320,7 @@ RETURN count(*) AS count ---- In a cluster, the `SHOW DATABASES` returns the number of allocations of databases and may be misleading if the number of distinct databases is desired. -In this case, the number of distinct databases hosted in a cluster can be seen using a `count()` aggregation with `YIELD` and `RETURN` with `name` instead of the wildcard. +In this case, the `count()` function can be used in the `RETURN` clause to aggregate the number of `DISTINCT` database names: .Query [source, cypher] From 4c7d3f2accc75961e5803ae4874b613120275f32 Mon Sep 17 00:00:00 2001 From: AlexicaWright <49636617+AlexicaWright@users.noreply.github.com> Date: Mon, 4 Dec 2023 13:35:28 +0100 Subject: [PATCH 3/4] use only one example to not discriminate clusters --- .../standard-databases/manage-databases.adoc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc index 399c7dd3e..175fadb65 100644 --- a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc +++ b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc @@ -300,13 +300,13 @@ SHOW DATABASE movies YIELD * === Show the number of databases -The number of databases can be seen using a `count()` aggregation with `YIELD` and `RETURN`. +The number of distinct databases can be seen using `YIELD` and a `count()` function in the `RETURN` clause to aggregate the number of `DISTINCT` database names. .Query [source, cypher] ---- -SHOW DATABASES YIELD * -RETURN count(*) AS count +SHOW DATABASES YIELD name +RETURN count(DISTINCT name) AS count ---- .Result @@ -319,16 +319,7 @@ RETURN count(*) AS count +-------+ ---- -In a cluster, the `SHOW DATABASES` returns the number of allocations of databases and may be misleading if the number of distinct databases is desired. -In this case, the `count()` function can be used in the `RETURN` clause to aggregate the number of `DISTINCT` database names: - -.Query -[source, cypher] ----- -SHOW DATABASES YIELD name -RETURN count(DISTINCT name) AS count ----- - +By specifying the `name` column and sorting the results by distinct name, only the number of distinct databases are counted, **not** the number of allocations of databases in a clustered environment. === Show the default database From a9cfebc04d4626b10fb9390ea456adc22d541768 Mon Sep 17 00:00:00 2001 From: AlexicaWright <49636617+AlexicaWright@users.noreply.github.com> Date: Mon, 4 Dec 2023 14:20:20 +0100 Subject: [PATCH 4/4] addressed PR comment --- .../standard-databases/manage-databases.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc index 175fadb65..0c89e6b76 100644 --- a/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc +++ b/modules/ROOT/pages/database-administration/standard-databases/manage-databases.adoc @@ -300,7 +300,7 @@ SHOW DATABASE movies YIELD * === Show the number of databases -The number of distinct databases can be seen using `YIELD` and a `count()` function in the `RETURN` clause to aggregate the number of `DISTINCT` database names. +The number of distinct databases can be seen using `YIELD` and a `count()` function in the `RETURN` clause. .Query [source, cypher]