Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB to view the current operation db.currentOp ()

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MongoDB to view the current operation db.currentOp ()

Define

Db.currentOp ()

Returns the document of the operation information running on the database instance.

The db.currentOp () method has the following format:

Db.currentOp ()

The db.currentOp () method can use the following optional parameters:

Parameter type description

Operations Boolean value or document is optional. Specifies the action for the report. You can enter a Boolean value or a document.

Specifies the true, including idle connections and system operations.

Specify documents with query criteria and report only actions that match the criteria.

Behavior

If true is passed to db.currentOp (), the method returns information about all operations, including idle connections and system operations.

Db.currentOp (true)

Passing true is equivalent to passing a query document {'$all': true}.

If you pass a query document to db.currentOp (), only the current action that matches the query criteria is returned.

You can also specify that {'$all: true} query documents return information about all running operations, including idle connections and system operations. If

The query document includes'$all':true and other query criteria, and only'$all':true'is applied.

access control

To run user authorization authentication on the system, the user must have access to the inprog behavior.

Example

The following example uses the db.currentOp () method with different query documents to filter the output.

Write operation waiting for lock

The following example returns all write information that is waiting for a lock:

Db.currentOp ({"waitingForLock": true, $or: [{"op": {"$in": ["insert", "update", "remove"]}}, {"query.findandmodify": {$exists: true}}]})

There is no active operation for Yields

The following example returns information about all active operations that are running without Yields:

Db.currentOp ({"active": true, "numYields": 0, "waitingForLock": false})

Active operations for a specific database

The following example returns all active operations that take more than 3 seconds to run for the database db1:

Db.currentOp ({"active": true, "secs_running": {"$gt": 3}, "ns": / ^ db1\. /})

Active index operation

The following example returns information about the index creation operation:

Db.currentOp ({$or: [{op: "query", "query.createIndexes": {$exists: true}}, {op: "insert", ns: / / .system\ .resume\ b /}]})

See: https://docs.mongodb.org/manual/reference/method/db.currentOp/

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report