Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOCS-14452 view in log #5938

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions source/reference/log-messages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1330,3 +1330,87 @@ attribute object:
"request": "RemoteCommand 229 -- target:localhost:27003 db:admin cmd:{ replSetRequestVotes: 1, setName: \"my-replica-name\", dryRun: true, term: 3, candidateIndex: 0, configVersion: 2, configTerm: 3, lastAppliedOpTime: { ts: Timestamp(1589915409, 1), t: 3 } }"
}
}

.. _log-message-view-example:

View
~~~~

Starting in MongoDB 5.0, :ref:`log messages for slow queries
<log-message-slow-ops>` on :doc:`views </core/views>` include a
``resolvedViews`` field that contains the view details:

.. code-block:: javascript
:copyable: false

"resolvedViews": [ {
"viewNamespace": <String>, // namespace and view name
"dependencyChain": <Array of strings>, // view name and collection
"resolvedPipeline": <Array of documents> // aggregation pipeline for view
} ]

The following example uses the ``test`` database and creates a view
named ``myView`` that sorts the documents in ``myCollection`` by the
``firstName`` field:

.. code-block:: javascript

use test
db.createView( "myView", "myCollection", [ { $sort: { "firstName" : 1 } } ] )

Assume a :ref:`slow query <log-message-slow-ops>` is run on ``myView``.
The following example log message contains a ``resolvedViews`` field for
``myView``:

.. code-block:: javascript
:copyable: false

{
"t": {
"$date": "2021-09-30T17:53:54.646+00:00"
},
"s": "I",
"c": "COMMAND",
"id": 51803,
"ctx": "conn249",
"msg": "Slow query",
"attr": {
"type": "command",
"ns": "test.myView",
"appName": "MongoDB Shell",
"command": {
"find": "myView",
"filter": {},
"lsid": {
"id": { "$uuid": "ad176471-60e5-4e82-b977-156a9970d30f" }
},
"$db": "test"
},
"planSummary":"COLLSCAN",
"resolvedViews": [ {
"viewNamespace": "test.myView",
"dependencyChain": [ "myView", "myCollection" ],
"resolvedPipeline": [ { "$sort": { "firstName": 1 } } ]
} ],
"keysExamined": 0,
"docsExamined": 1,
"hasSortStage": true,
"cursorExhausted": true,
"numYields": 0,
"nreturned": 1,
"queryHash": "3344645B",
"planCacheKey": "1D3DE690",
"reslen": 134,
"locks": { "ParallelBatchWriterMode": { "acquireCount": { "r": 1 } },
"ReplicationStateTransition": { "acquireCount": { "w": 1 } },
"Global": { "acquireCount": { "r": 4 } },
"Database": { "acquireCount": {"r": 1 } },
"Collection": { "acquireCount": { "r": 1 } },
"Mutex": { "acquireCount": { "r": 4 } } },
"storage": {},
"remote": "127.0.0.1:34868",
"protocol": "op_msg",
"durationMillis": 0
}
}
}
7 changes: 7 additions & 0 deletions source/release-notes/5.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,13 @@ Starting in MongoDB 5.0, you can use the :ref:`remoteOpWaitMillis
<log-messages-remoteOpWaitMillis>` log field to obtain the wait time for
results from :term:`shards <shard>`.

``resolvedViews`` Log Field for Slow Queries on Views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Starting in MongoDB 5.0, :ref:`log messages for slow queries
<log-message-slow-ops>` on :ref:`views <log-message-view-example>`
include a ``resolvedViews`` field that contains the view details.

Define Variables Using the ``let`` Option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down