REQUEST COMPLIMENTARY SQLS*PLUS LICENCE
Use Mongosniff to clarify what your MongoDB hears and says
Preamble
Writing an application on top of the framework on top of the driver on top of the database is a bit like a game on the phone: you say “insert foo”, and the database says “dishwasher with purple monkeys”.
Mongosniff allows you to see exactly what the database hears and says.
It comes with a binary distribution, so if you have a mongod, you should have mongosniff .
To try this, first, run the mongod instance as usual:
$ ./mongod
When you run mongosniff you must tell it to listen to the loopback interface (localhost). This interface is usually called “lo”, but my Mac calls it “lo0”, so run ifconfig to make sure you give it the right name. Now run it:
$ sudo ./mongosniff --source NET lo
sniffing... 27017
Note “sudo”: this never worked for me from my user account, probably because of some stupid network permissions.
Now run the Mongo shell and try to insert something:
db.foo.insert({x:1})
If you look at the mongosniff output, you will see:
127.0.0.1:57856 -->> 127.0.0.1:27017 test.foo 62 bytes id:430131ca 1124151754
insert: { _id: ObjectId('4c7fb007b5d697849addc650'), x: 1.0 }
127.0.0.1:57856 -->> 127.0.0.1:27017 test.$cmd 76 bytes id:430131cb 1124151755
query: { getlasterror: 1.0, w: 1.0 } ntoreturn: -1 ntoskip: 0
127.0.0.1:27017 <<-- 127.0.0.1:57856 76 bytes id:474447bf 1195657151 - 1124151755
reply n:1 cursorId: 0
{ err: null, n: 0, wtime: 0, ok: 1.0 }
There are three requests, all for one miserable insert. By cutting the first request, we can find out:
source – >>
place of destination
Our client,
In this case, mongo , works through port 57856 and sent a message to the database (127.0.0.1:27017).
dB
collection
This query is for the “foo” collection of the “test” database.
Byte length
The request length is 62 bytes. This may be convenient if your requests are close to the maximum request length (16 MB).
id:
hexadecimal
identifier
This is the request ID in hexadecimal and decimal form (in case you do not have a computer, obviously). Each query to the database has a unique identifier associated with it for tax purposes.
op :
content .
This is the actual content of the request: we insert this document. Note that it inserts a floating point value of 1.0 although we have entered 1 in the shell. This is because JavaScript has only one number type, so each number entered in the shell is converted to a double.
The next request in the output of mongosniff is the database command: it checks that the insertion is successful (the shell always performs safe inserts).
The last message heard is slightly different: it goes from database to shell. This is the database response to the getlasterror command. It shows that only one document was returned (answer n: 1) and that there are no more results waiting in the database (cursorId: 0). If this was a “real” query and there was another package of results to send from the database, cursorId would be non-zero.
MongoDB In 30 Minutes
Enteros
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of RDBMS, NoSQL, and machine learning database platforms.
MORE NEWS
PreambleNoSql is not a replacement for SQL databases but is a valid alternative for many situations where standard SQL is not the best approach for...
PreambleMongoDB Conditional operators specify a condition to which the value of the document field shall correspond.Comparison Query Operators $eq...
5 Database management trends impacting database administrationIn the realm of database management systems, moreover half (52%) of your competitors feel...
The data type is defined as the type of data that any column or variable can store in MS SQL Server. What is the data type? When you create any table or...
PreambleMS SQL Server is a client-server architecture. MS SQL Server process starts with the client application sending a query.SQL Server accepts,...
First the basics: what is the master/slave?One database server (“master”) responds and can do anything. A lot of other database servers store copies of all...
PreambleAtom Hopper (based on Apache Abdera) for those who may not know is an open-source project sponsored by Rackspace. Today we will figure out how to...
PreambleMongoDB recently introduced its new aggregation structure. This structure provides a simpler solution for calculating aggregated values rather...
FlexibilityOne of the most advertised features of MongoDB is its flexibility. Flexibility, however, is a double-edged sword. More flexibility means more...
PreambleSQLShell is a cross-platform command-line tool for SQL, similar to psql for PostgreSQL or MySQL command-line tool for MySQL.Why use it?If you...
PreambleOracle Coherence is a distributed cache that is functionally comparable with Memcached. In addition to the basic function of the API cache, it...
PreambleIBM pureXML, a proprietary XML database built on a relational mechanism (designed for puns) that offers both relational ( SQL / XML ) and...
What is PostgreSQL array? In PostgreSQL we can define a column as an array of valid data types. The data type can be built-in, custom or enumerated....
PreambleIf you are a Linux sysadmin or developer, there comes a time when you need to manage an Oracle database that can work in your environment.In this...
PreambleStarting with Microsoft SQL Server 2008, by default, the group of local administrators is no longer added to SQL Server administrators during the...
PreambleWhen administering PostgreSQL database servers, one of the most common tasks you will probably perform is enumerating databases and their tables....