Skip to content

Commit 7720931

Browse files
jmd-mongojeff-allen-mongo
authored andcommitted
DOCS-14020 documents listDatabase output changes for 5.0
1 parent f453a46 commit 7720931

File tree

2 files changed

+124
-27
lines changed

2 files changed

+124
-27
lines changed

source/reference/command/listDatabases.txt

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -101,37 +101,14 @@ Definition
101101

102102
.. versionadded:: 4.4
103103

104-
105-
Output
106-
------
107-
108-
:dbcommand:`listDatabases` returns a document that contains:
109-
110-
- A field named ``databases`` whose value is an array of documents, one
111-
document for each database. Each document contains:
112-
113-
- A ``name`` field with the database name.
114-
115-
- A ``sizeOnDisk`` field with the total size of the database files on
116-
disk in bytes.
117-
118-
- An ``empty`` field specifying whether the database has any data.
119-
120-
- For sharded clusters, a ``shards`` field that includes the shard
121-
and the size in bytes of the database on disk for each shard.
122-
123-
- A field named ``totalSize`` whose value is the sum of all the
124-
``sizeOnDisk`` fields in bytes.
125-
126104
.. _listDatabases-behavior:
127105

128106
Behavior
129107
--------
130108

131109
When :doc:`authentication </core/authentication>` is enabled:
132110

133-
.. note:: show dbs
134-
111+
.. note::
135112

136113
For :binary:`~bin.mongo` shell version 4.0.6+ connected to earlier
137114
versions of MongoDB deployment (e.g. 3.6.10),
@@ -238,6 +215,7 @@ The following is an example of a :dbcommand:`listDatabases` result:
238215
}
239216
],
240217
"totalSize" : 251658240,
218+
"totalSizeMb" : 251,
241219
"ok" : 1
242220
}
243221

@@ -290,6 +268,8 @@ name matches the specified :query:`regular expression <$regex>`:
290268

291269
db.adminCommand( { listDatabases: 1, filter: { "name": /^rep/ } } )
292270

271+
.. _listDatabases-sharded-clusters:
272+
293273
Sharded Clusters
294274
~~~~~~~~~~~~~~~~
295275

@@ -345,9 +325,66 @@ For example:
345325
"ok" : 1
346326
}
347327

348-
.. seealso::
349-
328+
.. seealso::
329+
350330
:doc:`/tutorial/use-database-commands`.
351331

332+
Output
333+
------
334+
335+
.. data:: listDatabases.databases
336+
337+
*Type: Array*
338+
339+
Array of documents, each containing information on a single
340+
database.
341+
342+
.. data:: listDatabases.databases.name
343+
344+
*Type: String*
345+
346+
Name of the database.
347+
348+
.. data:: listDatabases.databases.sizeOnDisk
349+
350+
*Type: Integer*
351+
352+
Total size of the database files on disk, expressed in bytes.
353+
354+
.. data:: listDatabases.databases.empty
355+
356+
*Type: Boolean*
357+
358+
Specifies whether the database is empty.
359+
360+
.. data:: listDatabases.databases.shards
361+
362+
*Type: Document*
363+
364+
Each element in the ``shards`` document consists of a field whose key
365+
gives the name of a collection on that shard, and whose value
366+
represents the collection's size in bytes.
367+
368+
``shards`` only appears in the output if ``nameOnly: false``.
369+
370+
See :ref:`Sharded Clusters <listDatabases-sharded-clusters>`
371+
for details.
372+
373+
.. data:: listDatabases.totalSize
374+
375+
*Type: Integer*
376+
377+
Sum of all the ``sizeOnDisk`` fields in bytes.
378+
379+
.. data:: listDatabases.totalSizeMb
380+
381+
*Type: Integer*
382+
383+
Sum of all the ``sizeOnDisk`` fields, expressed in megabytes.
384+
385+
.. data:: listDatabases.ok
386+
387+
*Type: Integer*
352388

353-
.. |checkmark| unicode:: U+2713
389+
Return value for the command. A value of ``1`` indicates
390+
success.

source/release-notes/5.0-compatibility.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,66 @@ operand expression ( ``{ }`` ):
131131
An empty update results in no changes and no :term:`oplog` entry is
132132
created (meaning that the operation is a no-op).
133133

134+
``listDatabases`` Output Changes
135+
--------------------------------
136+
137+
Starting in MongoDB 5.0, output from the :dbcommand:`listDatabases`
138+
command running against a :binary:`~bin.mongod` is more consistent with
139+
output from :dbcommand:`listDatabases` running against a
140+
:binary:`~bin.mongos`.
141+
142+
The following table shows the differences in data types for
143+
:dbcommand:`listDatabases` output fields between MongoDB 5.0 and earlier
144+
versions. Only fields which differ between 5.0 and earlier versions are
145+
listed.
146+
147+
.. list-table::
148+
:header-rows: 1
149+
:widths: 25 25 25 25
150+
151+
* - Field
152+
153+
- Type in MongoDB 5.0
154+
155+
- Type in MongoDB 4.4 and earlier (``mongod``)
156+
157+
- Type in MongoDB 4.4 and earlier (``mongos``)
158+
159+
* - ``sizeOnDisk``
160+
161+
- integer
162+
163+
- double
164+
165+
- integer
166+
167+
* - ``totalSize``
168+
169+
- integer
170+
171+
- double
172+
173+
- integer
174+
175+
* - ``totalSizeMb``
176+
177+
- integer
178+
179+
- not present (see below)
180+
181+
- integer
182+
183+
The output from :dbcommand:`listDatabases` now includes the
184+
``totalSizeMb`` field when run against either a :binary:`~bin.mongos` or
185+
a :binary:`~bin.mongod`. In MongoDB 4.4 and earlier, ``totalSizeMb``
186+
only appears when run against :binary:`~bin.mongos`. ``totalSizeMb`` is
187+
the sum of the ``sizeOnDisk`` fields, expressed in megabytes.
188+
189+
When run against :binary:`~bin.mongos`, the ``shards`` field in the
190+
:dbcommand:`listDatabases` output contains a field-value pair for each
191+
collection on a particular shard. Size values in the ``shards`` field
192+
are expressed as integers.
193+
134194
General Changes
135195
---------------
136196

0 commit comments

Comments
 (0)