Skip to content

Commit 5f1eb5a

Browse files
(DOCSP-24007) Improve sbe performance (#3245)
* (DOCSP-29528): Improve SBE release notes (#3068) (#3083) * (DOCSP-29528): Improve SBE release notes * wording tweak * wording * change section title * (DOCSP-29529): Update log messages for SBE 7.0 changes (#3224) * (DOCSP-29529): Update log messages for SBE 7.0 changes * line spacing * copy review edits * wording * update release version * DOCSP-29530 Adjust $planCacheStats output for SBE (#3201) * formatting tabs * fix build error * formatting tab title * add more sbe content * fill out SBE table * try to fix linting * edit examples * remove version added for SBE * add version changed * fix formatting for code block * single sourcing * fix ref errors * wording * remove 'i.e.' * format field names in table * fix spacing for example comments * address review comments * Update source/includes/planCacheStats/indexFilterSet.rst Co-authored-by: Ruoxin Xu <[email protected]> * fix cachedPlan link * wording --------- Co-authored-by: Ruoxin Xu <[email protected]> --------- Co-authored-by: Ruoxin Xu <[email protected]>
1 parent f7c2356 commit 5f1eb5a

File tree

16 files changed

+399
-570
lines changed

16 files changed

+399
-570
lines changed

snooty.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ windows-sha256 = "C777DF7816BB8C9A760FDEA782113949408B6F39D72BE29A2551FA51E2FE04
247247
source-available = ":github:`source available and free to use <mongodb/mongo>`"
248248
pcre-abbr = ":abbr:`PCRE (Perl Compatible Regular Expressions)`"
249249
pcre = "Perl Compatible Regular Expressions"
250+
sbe = "slot-based query execution engine"
251+
sbe-short = "slot-based engine"
252+
sbe-title = "Slot-Based Query Execution Engine"
250253
fcv = ":abbr:`fCV (feature compatibility version)`"
251254
fts = "Atlas Search"
252255
# In Use Encryption Constants
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The details of the cached plan. The fields included in the
2+
``cachedPlan`` vary based on whether the query was completed using the
3+
classic engine or the {+sbe+}. For more information on query plans, see
4+
:data:`explain.queryPlanner`.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The estimated size in bytes of a plan cache entry.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The hostname and port of the :binary:`~bin.mongod` instance from which
2+
the plan cache information was returned.
3+
4+
When run on a sharded cluster, the operation returns plan cache entry
5+
information from a single member in each shard replica set. This member
6+
is identified with the :ref:`shard <plancachestats-shard>` and
7+
:ref:`host <plancachestats-host>` fields. See also
8+
:ref:`plancachestats-read-pref`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A boolean that indicates whether an :ref:`index filter
2+
<index-filters>` exists for the query shape.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
A boolean that indicates whether the entry is active or inactive.
2+
3+
- If active, the query planner is currently using the entry to generate
4+
query plans.
5+
6+
- If inactive, the query planner is not currently using the entry to
7+
generate query plans.
8+
9+
See :ref:`cache-entry-state`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
A hexadecimal string that represents the hash of the key used to find
2+
the plan cache entry associated with this query. The plan cache key is a
3+
function of both the query shape and the currently available indexes for
4+
that shape. See :data:`explain.queryPlanner.planCacheKey`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
A hexadecimal string that represents the hash of the :term:`query
2+
shape`. See :data:`explain.queryPlanner.queryHash`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
A number that indicates the query engine used to complete the query.
2+
3+
- ``1`` indicates that the classic engine was used.
4+
5+
- ``2`` indicates that the :ref:`{+sbe+} <5.1-rel-notes-sbe>` was used.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The number of "work units" performed by the query execution plan during
2+
the trial period when the query planner evaluates candidate plans. For
3+
more information, see
4+
:data:`explain.executionStats.executionStages.works`.

source/reference/command/planCacheClear.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ The command takes the following optional fields:
7676

7777

7878
To see the query shapes for which cached query plans exist, see
79-
:ref:`planCacheStats-list-query-shapes`.
79+
:ref:`planCacheStats-examples`.
8080

8181
Required Access
8282
---------------

source/reference/log-messages.txt

Lines changed: 39 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,23 +1009,24 @@ Starting in MongoDB 5.0, :ref:`slow operation
10091009
<database-profiling-specify-slowms-threshold>` log messages include a
10101010
``remote`` field specifying client IP address.
10111011

1012+
Starting in MongoDB 6.2, slow operation log messages include a
1013+
``queryFramework`` field that indicates which query engine completed the
1014+
query:
1015+
1016+
- ``queryFramework: "classic"`` indicates that the classic engine
1017+
completed the query.
1018+
1019+
- ``queryFramework: "sbe"`` indicates that the {+sbe+} completed the
1020+
query.
1021+
10121022
Starting in MongoDB 6.3, :ref:`slow operation
10131023
<database-profiling-specify-slowms-threshold>` log messages and :ref:`database
10141024
profiler <profiler>` entries include a ``cpuNanos`` field that specifies the
10151025
total CPU time spent by a query operation in nanoseconds. The ``cpuNanos`` field
10161026
is only available on Linux systems.
10171027

1018-
The following example output includes information about
1019-
a slow :doc:`aggregation </aggregation>` operation:
1020-
1021-
.. code-block:: javascript
1022-
:copyable: false
1023-
1024-
{"t":{"$date":"2020-05-20T20:10:08.731+00:00"},"s":"I", "c":"COMMAND", "id":51803, "ctx":"conn281","msg":"Slow query","attr":{"type":"command","ns":"stocks.trades","appName":"MongoDB Shell","command":{"aggregate":"trades","pipeline":[{"$project":{"ticker":1.0,"price":1.0,"priceGTE110":{"$gte":["$price",110.0]},"_id":0.0}},{"$sort":{"price":-1.0}}],"allowDiskUse":true,"cursor":{},"lsid":{"id":{"$uuid":"fa658f9e-9cd6-42d4-b1c8-c9160fabf2a2"}},"$clusterTime":{"clusterTime":{"$timestamp":{"t":1590005405,"i":1}},"signature":{"hash":{"$binary":{"base64":"AAAAAAAAAAAAAAAAAAAAAAAAAAA=","subType":"0"}},"keyId":0}},"$db":"test"},"planSummary":"COLLSCAN","cursorid":1912190691485054730,"keysExamined":0,"docsExamined":1000001,"hasSortStage":true,"usedDisk":true,"numYields":1002,"nreturned":101,"reslen":17738,"locks":{"ReplicationStateTransition":{"acquireCount":{"w":1119}},"Global":{"acquireCount":{"r":1119}},"Database":{"acquireCount":{"r":1119}},"Collection":{"acquireCount":{"r":1119}},"Mutex":{"acquireCount":{"r":117}}},"storage":{"data":{"bytesRead":232899899,"timeReadingMicros":186017},"timeWaitingMicros":{"cache":849}},"cpuNanos":22426151000,"remote": "192.168.14.15:37666","protocol":"op_msg","durationMillis":22427}}
1025-
1026-
See the :ref:`examples section <log-message-json-examples>` for a
1027-
:ref:`pretty-printed <log-message-pretty-printing>` version of this log
1028-
entry.
1028+
For a :ref:`pretty-printed <log-message-pretty-printing>` example of a
1029+
slow operation log entry, see :ref:`log-message-json-examples`.
10291030

10301031
.. _log-messages-remoteOpWaitMillis:
10311032

@@ -1363,116 +1364,59 @@ This example shows a :ref:`slow operation message
13631364

13641365
{
13651366
"t": {
1366-
"$date": "2020-05-20T20:10:08.731+00:00"
1367+
"$date": "2023-05-24T13:46:27.853+00:00"
13671368
},
13681369
"s": "I",
13691370
"c": "COMMAND",
13701371
"id": 51803,
1371-
"ctx": "conn281",
1372+
"ctx": "conn3",
13721373
"msg": "Slow query",
13731374
"attr": {
13741375
"type": "command",
1375-
"ns": "stocks.trades",
1376+
"ns": "db.coll",
13761377
"appName": "MongoDB Shell",
13771378
"command": {
1378-
"aggregate": "trades",
1379-
"pipeline": [
1380-
{
1381-
"$project": {
1382-
"ticker": 1,
1383-
"price": 1,
1384-
"priceGTE110": {
1385-
"$gte": [
1386-
"$price",
1387-
110
1388-
]
1389-
},
1390-
"_id": 0
1391-
}
1392-
},
1393-
{
1394-
"$sort": {
1395-
"price": -1
1396-
}
1397-
}
1398-
],
1399-
"allowDiskUse": true,
1400-
"cursor": {},
1379+
"find": "coll",
1380+
"filter": {
1381+
"b": -1
1382+
},
14011383
"lsid": {
14021384
"id": {
1403-
"$uuid": "fa658f9e-9cd6-42d4-b1c8-c9160fabf2a2"
1404-
}
1405-
},
1406-
"$clusterTime": {
1407-
"clusterTime": {
1408-
"$timestamp": {
1409-
"t": 1590005405,
1410-
"i": 1
1411-
}
1412-
},
1413-
"signature": {
1414-
"hash": {
1415-
"$binary": {
1416-
"base64": "AAAAAAAAAAAAAAAAAAAAAAAAAAA=",
1417-
"subType": "0"
1418-
}
1419-
},
1420-
"keyId": 0
1385+
"$uuid": "5d50b19c-8559-420a-a122-8834e012274a"
14211386
}
14221387
},
1423-
"$db": "test"
1388+
"$db": "db"
14241389
},
14251390
"planSummary": "COLLSCAN",
1426-
"cursorid": 1912190691485054700,
1391+
"planningTimeMicros": 228,
14271392
"keysExamined": 0,
1428-
"docsExamined": 1000001,
1429-
"hasSortStage": true,
1430-
"usedDisk": true,
1431-
"mirrored": false,
1432-
"numYields": 1002,
1433-
"nreturned": 101,
1434-
"queryFramework": "classic"
1435-
"reslen": 17738,
1393+
"docsExamined": 232922,
1394+
"fromPlanCache": true,
1395+
"nBatches": 1,
1396+
"cursorExhausted": true,
1397+
"numYields": 232,
1398+
"nreturned": 0,
1399+
"queryHash": "9C05019A",
1400+
"planCacheKey": "C41063D6",
1401+
"queryFramework": "sbe",
1402+
"reslen": 96,
14361403
"locks": {
1437-
"ReplicationStateTransition": {
1404+
"FeatureCompatibilityVersion": {
14381405
"acquireCount": {
1439-
"w": 1119
1406+
"r": 233
14401407
}
14411408
},
14421409
"Global": {
14431410
"acquireCount": {
1444-
"r": 1119
1411+
"r": 233
14451412
}
1446-
},
1447-
"Database": {
1448-
"acquireCount": {
1449-
"r": 1119
1450-
}
1451-
},
1452-
"Collection": {
1453-
"acquireCount": {
1454-
"r": 1119
1455-
}
1456-
},
1457-
"Mutex": {
1458-
"acquireCount": {
1459-
"r": 117
1460-
}
1461-
}
1462-
},
1463-
"storage": {
1464-
"data": {
1465-
"bytesRead": 232899899,
1466-
"timeReadingMicros": 186017
1467-
},
1468-
"timeWaitingMicros": {
1469-
"cache": 849
14701413
}
14711414
},
1472-
"cpuNanos": 22426151000,
1473-
"remote": "192.168.14.15:37666",
1415+
"storage": {},
1416+
"cpuNanos": 111410254,
1417+
"remote": "127.0.0.1:47150",
14741418
"protocol": "op_msg",
1475-
"durationMillis": 22427
1419+
"durationMillis": 111
14761420
}
14771421
}
14781422

source/reference/method/PlanCache.clearPlansByQuery.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Definition
7171

7272

7373
To see the query shapes for which cached query plans exist, see
74-
:ref:`planCacheStats-list-query-shapes`.
74+
:ref:`planCacheStats-examples`.
7575

7676
Required Access
7777
---------------

0 commit comments

Comments
 (0)