Skip to content

Commit facf868

Browse files
jason-price-mongodbjeff-allen-mongo
jason-price-mongodb
authored andcommitted
DOCS-14452 view in log
1 parent d3751b3 commit facf868

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

source/reference/log-messages.txt

+84
Original file line numberDiff line numberDiff line change
@@ -1330,3 +1330,87 @@ attribute object:
13301330
"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 } }"
13311331
}
13321332
}
1333+
1334+
.. _log-message-view-example:
1335+
1336+
View
1337+
~~~~
1338+
1339+
Starting in MongoDB 5.0, :ref:`log messages for slow queries
1340+
<log-message-slow-ops>` on :doc:`views </core/views>` include a
1341+
``resolvedViews`` field that contains the view details:
1342+
1343+
.. code-block:: javascript
1344+
:copyable: false
1345+
1346+
"resolvedViews": [ {
1347+
"viewNamespace": <String>, // namespace and view name
1348+
"dependencyChain": <Array of strings>, // view name and collection
1349+
"resolvedPipeline": <Array of documents> // aggregation pipeline for view
1350+
} ]
1351+
1352+
The following example uses the ``test`` database and creates a view
1353+
named ``myView`` that sorts the documents in ``myCollection`` by the
1354+
``firstName`` field:
1355+
1356+
.. code-block:: javascript
1357+
1358+
use test
1359+
db.createView( "myView", "myCollection", [ { $sort: { "firstName" : 1 } } ] )
1360+
1361+
Assume a :ref:`slow query <log-message-slow-ops>` is run on ``myView``.
1362+
The following example log message contains a ``resolvedViews`` field for
1363+
``myView``:
1364+
1365+
.. code-block:: javascript
1366+
:copyable: false
1367+
1368+
{
1369+
"t": {
1370+
"$date": "2021-09-30T17:53:54.646+00:00"
1371+
},
1372+
"s": "I",
1373+
"c": "COMMAND",
1374+
"id": 51803,
1375+
"ctx": "conn249",
1376+
"msg": "Slow query",
1377+
"attr": {
1378+
"type": "command",
1379+
"ns": "test.myView",
1380+
"appName": "MongoDB Shell",
1381+
"command": {
1382+
"find": "myView",
1383+
"filter": {},
1384+
"lsid": {
1385+
"id": { "$uuid": "ad176471-60e5-4e82-b977-156a9970d30f" }
1386+
},
1387+
"$db": "test"
1388+
},
1389+
"planSummary":"COLLSCAN",
1390+
"resolvedViews": [ {
1391+
"viewNamespace": "test.myView",
1392+
"dependencyChain": [ "myView", "myCollection" ],
1393+
"resolvedPipeline": [ { "$sort": { "firstName": 1 } } ]
1394+
} ],
1395+
"keysExamined": 0,
1396+
"docsExamined": 1,
1397+
"hasSortStage": true,
1398+
"cursorExhausted": true,
1399+
"numYields": 0,
1400+
"nreturned": 1,
1401+
"queryHash": "3344645B",
1402+
"planCacheKey": "1D3DE690",
1403+
"reslen": 134,
1404+
"locks": { "ParallelBatchWriterMode": { "acquireCount": { "r": 1 } },
1405+
"ReplicationStateTransition": { "acquireCount": { "w": 1 } },
1406+
"Global": { "acquireCount": { "r": 4 } },
1407+
"Database": { "acquireCount": {"r": 1 } },
1408+
"Collection": { "acquireCount": { "r": 1 } },
1409+
"Mutex": { "acquireCount": { "r": 4 } } },
1410+
"storage": {},
1411+
"remote": "127.0.0.1:34868",
1412+
"protocol": "op_msg",
1413+
"durationMillis": 0
1414+
}
1415+
}
1416+
}

source/release-notes/5.0.txt

+7
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,13 @@ Starting in MongoDB 5.0, you can use the :ref:`remoteOpWaitMillis
827827
<log-messages-remoteOpWaitMillis>` log field to obtain the wait time for
828828
results from :term:`shards <shard>`.
829829

830+
``resolvedViews`` Log Field for Slow Queries on Views
831+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832+
833+
Starting in MongoDB 5.0, :ref:`log messages for slow queries
834+
<log-message-slow-ops>` on :ref:`views <log-message-view-example>`
835+
include a ``resolvedViews`` field that contains the view details.
836+
830837
Define Variables Using the ``let`` Option
831838
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832839

0 commit comments

Comments
 (0)