Comments (10)
The version from Docker is 2.0.2 while the latest version is 2.2.0, I have to update the MongoDB version in Docker but I can't now, and since 2.0.2 I added support to many types of registries, could you install the latest Mongotail version with pip
in your system?
If you cannot install it globally with sudo
you can install it in the Python user install directory with:
$ pip install --user mongotail
The problem with it is that the command mongotail
will be placed at ~/.local/bin/mongotail
, so you have to append the ~/.local/bin
directory to your $PATH
environment variable, or execute Mongotail with the full path in the command line.
from mongotail.
Now he made no mistake.
execute
db.getCollection('shop').find({"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}).limit(2)
mongotail db -f output
2020-04-06 12:57:47.131 QUERY [shop] : {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}. 2 returned.
It's not what I want.
I didn't see the limit message
from mongotail.
@mrsarm mongotail version
mongotail 2.3.0 <https://github.com/mrsarm/mongotail> (python 3.7.0)
mongodb version 4.1.13
from mongotail.
As much I remember the limit
argument you pass is not recorded by the profiler at least in modern version of MongoDB. But lets be sure because there were some changes in the profiler format that then were roll-backed, please execute the same query but passing as limit another number like 999, and then execute mongotail in verbose mode like this mongotail db -v -f
, and lets check whether the 999 is present in the output, if it's there, I can make a patch.
from mongotail.
When I execute the order : mongotail db -v -f
Request api , I get this result:
{"op": "query", "ns": "xx.shop", "command": {"find": "shop", "filter": {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6"), "status": 1}, "sort": {"created_at": -1}, "projection": {"updated_at": 0, "deleted_at": 0}, "skip": 6, "limit": 2, "batchSize": 2, "$db": "xx"}, "keysExamined": 7, "docsExamined": 7, "hasSortStage": true, "cursorExhausted": true, "numYield": 0, "nreturned": 1, "queryHash": "E9D3CA53", "planCacheKey": "05B3EA84", "locks": {"ReplicationStateTransition": {"acquireCount": {"w": 1}}, "Global": {"acquireCount": {"r": 1}}, "Database": {"acquireCount": {"r": 1}}, "Collection": {"acquireCount": {"r": 1}}, "Mutex": {"acquireCount": {"r": 1}}}, "flowControl": {}, "responseLength": 267, "protocol": "op_query", "millis": 0, "planSummary": "IXSCAN { user_id: 1 }", "execStats": {"stage": "PROJECTION_DEFAULT", "nReturned": 1, "executionTimeMillisEstimate": 0, "works": 17, "advanced": 1, "needTime": 15, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 1, "transformBy": {
{"op": "command", "ns": "xx.shop", "command": {"count": "shop", "query": {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6"), "status": 1}, "$db": "xx"}, "keysExamined": 7, "docsExamined": 7, "numYield": 0, "queryHash": "08C653AC", "planCacheKey": "AFF8AF5F", "locks": {"ReplicationStateTransition": {"acquireCount": {"w": 1}}, "Global": {"acquireCount": {"r": 1}}, "Database": {"acquireCount": {"r": 1}}, "Collection": {"acquireCount": {"r": 1}}, "Mutex": {"acquireCount": {"r": 1}}}, "flowControl": {}, "responseLength": 60, "protocol": "op_query", "millis": 0, "planSummary": "IXSCAN { user_id: 1 }", "execStats": {"stage": "COUNT", "nReturned": 0, "executionTimeMillisEstimate": 0, "works": 8, "advanced": 0, "needTime": 7, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 1, "nCounted": 7, "nSkipped": 0, "inputStage": {"stage": "FETCH", "filter": {"status": {"$eq": 1}}, "nReturned": 7, "executionTimeMillisEstimate": 0, "works": 8, "advanced": 7, "needTime": 0, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 1, "docsExamined": 7, "alreadyHasObj": 0, "inputStage": {"stage": "IXSCAN", "nReturned": 7, "executionTimeMillisEstimate": 0, "works": 8, "advanced": 7, "needTime": 0, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 1, "keyPattern": {"user_id": 1}, "indexName": "idx_user_id", "isMultiKey": false, "multiKeyPaths": {"user_id": []}, "isUnique": false, "isSparse": false, "isPartial": false, "indexVersion": 2, "direction": "forward", "indexBounds": {"user_id": ["[ObjectId("'5e8b0782e6c7600dd858e3f6'), ObjectId("'5e8b0782e6c7600dd858e3f6')]"]}, "keysExamined": 7, "seeks": 1, "dupsTested": 0, "dupsDropped": 0}}}, "ts": ISODate("2020-04-07T02:03:57.720Z"), "client": "0.0.0.0", "allUsers": [{"user": "admin", "db": "admin"}], "user": "admin@admin"}
Use Robo 3T 1.3.1, How do I implement that?
from mongotail.
OK, I could reproduce the what you say, checking the code ...
from mongotail.
Surprisingly mongotail currently does not support the pagination params limit
and skip
, I think the reason is because this information was not available in Mongo < 3.2, since 3.2 the format changed a lot, and these values are stored, so I added in this branch support for both arguments.
Try upgrade to the beta release of the branch with:
$ pip install --upgrade https://github.com/mrsarm/mongotail/archive/imp-mongo-pagination.zip
Change pip
by pip3
if you have previously installed it with Python 3, and prepend to the command sudo
if you are installing it globally.
Try and let me know the result, now executing this (also used skip
):
db.getCollection('shop').find({"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}).limit(2).skip(10)
You get something like this:
2020-04-07 19:19:34.485 QUERY [shop] : {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}, limit: 2, skip: 10. 0 returned.
from mongotail.
I carried out the order:
pip install --upgrade https://github.com/mrsarm/mongotail/archive/imp-mongo-pagination.zip
Robo 3T executes the command:
db.getCollection('shop').find({"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}).limit(1).skip(1)
For db -v -f get:
{"op": "query", "ns": "merchant.shop", "command": {"find": "shop", "filter": {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}, "skip": 1.0, "limit": 1.0, "singleBatch": false, "lsid": {"id": UUID("0fdc024d-bf86-4e8e-aaca-a34c28619ea6")}, "$readPreference": {"mode": "secondaryPreferred"}, "$db": "merchant"}, "keysExamined": 2, "docsExamined": 1, "cursorExhausted": true, "numYield": 0, "nreturned": 1, "queryHash": "D6EECA37", "planCacheKey": "4C856ECA", "locks": {"ReplicationStateTransition": {"acquireCount": {"w": 1}}, "Global": {"acquireCount": {"r": 1}}, "Database": {"acquireCount": {"r": 1}}, "Collection": {"acquireCount": {"r": 1}}, "Mutex": {"acquireCount": {"r": 1}}}, "flowControl": {}, "responseLength": 289, "protocol": "op_msg", "millis": 0, "planSummary": "IXSCAN { user_id: 1 }", "execStats": {"stage": "LIMIT", "nReturned": 1, "executionTimeMillisEstimate": 0, "works": 3, "advanced": 1, "needTime": 1, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 1, "limitAmount": 1, "inputStage": {"stage": "FETCH", "nReturned": 1, "executionTimeMillisEstimate": 0, "works": 2, "advanced": 1, "needTime": 1, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 0, "docsExamined": 1, "alreadyHasObj": 0, "inputStage": {"stage": "SKIP", "nReturned": 1, "executionTimeMillisEstimate": 0, "works": 2, "advanced": 1, "needTime": 1, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 0, "skipAmount": 0, "inputStage": {"stage": "IXSCAN", "nReturned": 2, "executionTimeMillisEstimate": 0, "works": 2, "advanced": 2, "needTime": 0, "needYield": 0, "saveState": 0, "restoreState": 0, "isEOF": 0, "keyPattern": {"user_id": 1}, "indexName": "idx_user_id", "isMultiKey": false, "multiKeyPaths": {"user_id": []}, "isUnique": false, "isSparse": false, "isPartial": false, "indexVersion": 2, "direction": "forward", "indexBounds": {"user_id": ["[ObjectId("'5e8b0782e6c7600dd858e3f6'), ObjectId("'5e8b0782e6c7600dd858e3f6')]"]}, "keysExamined": 2, "seeks": 1, "dupsTested": 0, "dupsDropped": 0}}}}, "ts": ISODate("2020-04-08T05:44:09.435Z"), "client": "0.0.0.0", "appName": "MongoDB Shell", "allUsers": [{"user": "root", "db": "merchant"}], "user": "root@merchant"}
For db -f get:
2020-04-08 05:44:22.298 QUERY [shop] : {"user_id": ObjectId("5e8b0782e6c7600dd858e3f6")}, limit: 1, skip: 1. 1 returned.
Thanks
from mongotail.
Thanks @im-zhangxi !
I'm going to merge the patch tomorrow and release Mongotail 2.4.0 with this feature.
from mongotail.
Version with the fix released:
- https://github.com/mrsarm/mongotail/releases/tag/2.4.0
- https://pypi.org/project/mongotail/2.4.0/
- New Docker registry (check README#docker): https://hub.docker.com/r/mrsarm/mongotail
from mongotail.
Related Issues (20)
- Mongotail EXCEPTION with $out operator in aggregation operation HOT 1
- `Mongotail EXCEPTION - Unknown command operation` when list collection indexes HOT 2
- Doesn't show sort properties HOT 3
- mongotail just closes HOT 12
- CPU runaway using `-f` option HOT 10
- ImportError: cannot import name string_type HOT 2
- list query log don't show HOT 2
- `mongotail [db] --follow` exits after 1 second HOT 7
- No support of bytes/binary data coming from MongDB HOT 7
- Mongotail EXCEPTION - Unknown registry HOT 8
- Error: 'utf8' codec can't decode byte 0x80 (binary field) HOT 3
- Supposed to work with Mongo 4.0.1? HOT 1
- MongoDB Timestamp type is not supported HOT 3
- Cannot get queries to log; only DROP and INSERT show in the log HOT 7
- Replace deprecated API methods from PyMongo
- Crash for queries containing `MaxKey` / `MinKey` HOT 13
- Error parsing command line: Invalid database "portal," HOT 3
- Connection to mongodb atlas not possible HOT 10
- mongotail 3.0.0 not compatible with res-address 2.0.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongotail.