Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I've imported 500k rows from an Oracle database to Mongodb to make some test. No indexes were added to the mongo collection.

I ran a query which did one aggregation on a column and one filtering on other column.

The result was the MongoDb query (aggregation framework) was 5 times slower then the oracles.

I'm just starting with MongoDb so maybe I'm missing something ?

share|improve this question

migrated from stackoverflow.com May 30 '13 at 10:39

This question came from our site for professional and enthusiast programmers.

"maybe I'm missing something" - indexes? –  Sergio Tulentsev May 30 '13 at 9:07
The aggregation framework is still slower than SQLs own in places atm, specifically $grouping and what not however, as Sergio says: what about indexes? I mean Oracle has indexes right? –  Sammaye May 30 '13 at 9:07
it also depends on your model. RDMBS and NoSQL are very different worlds. I'm not sure query benchmark are relevant, because you won't build your application the same manner with nosql or rdbms –  Steve B May 30 '13 at 9:08

3 Answers 3

Simple example when MongoDB will be faster that Oracle: save a customer with several postal addresses.

With oracle (actually any relational database), you will:

  1. Initiate a transaction
  2. Save the customer row
  3. for each address, save the address row, with a reference to the customer row
  4. Commit the transaction.

If you have, let's say, 3 addresses, you will have 4 inserts + the transaction cost.

With MongoDB (or any NoSQL database), you will:

  1. Save the customer document (including its sub property Addresses)

Here, you have only one insert. No transaction required, because you only execute one atomic insert.

On equivalent hardware, I'm quite sure MongoDB will be faster that Oracle.

But the actual conclusion is not that Oracle or MongoDB will be faster, but that comparing benchmarks between Nosql and RDMBS is a non-sense, because you won't build your apps in the same manner, both worlds have pro and cons that go far beyond speed comparison

share|improve this answer

Yes, Mongodb is slower than Oracle in almost any record-to-record comparison. The advantage of Mongodb is that you can store a free-form, denormalized document and so retrieve in a single key/value lookup what might take Oracle several table joins to put together, but that is only if you radically change your schema design in the process.

OK, there are other advantages to Mongodb, like easy sharding and replica sets and the flexibility to store and query documents without defining a schema in advance (and in fact to have documents with different schemas in the same collection) and free licensing and easy deployment, but in general Mongo is slower that Oracle across the board at doing what Oracle does best.

Plus it's ridiculous to compare unindexed databases that support indexes to indexed databases for performance.

share|improve this answer
It is a fact that MongoDB is slower, really? –  Sammaye May 30 '13 at 9:21
What you are offering is a biased and IMO undocumented comparison. A MongoDB cluster with replica sets, sharding and a proper multi-threaded backend leads to comparable, if not better performance. Text search, aggregation and other new features have yet to reach maturity in Mongo, but on a record to record basis performance is comparable at the very least. –  flav May 30 '13 at 9:26
On a record-by-record comparison with the same guarantees, Oracle will be faster. A single non-guaranteed write of a Mongo document vs a mutli-table transactionally guaranteed update of Oracle will usually be faster. It should be no surprise that Oracle is better at doing what it is specialized for, Mongo is better at doing what it is specialized for. Doing a sharded write in Mongo with a write concern waiting for confirmation from a majority of replicas is pretty slow compared to an Oracle update. Does Mongo even have a TPMc benchmark? –  Old Pro May 30 '13 at 9:26
@Sammaye: don't forget about hundreds (thousands?) of man-years of optimization in Oracle. –  Sergio Tulentsev May 30 '13 at 9:38
@Sammaye, so it seems that between you, me, Oracle, 10gen, and the mongodb-user google group, the only one who thinks Mongodb is just as fast as Oracle is you. –  Old Pro May 30 '13 at 10:00

If you run query and columns in filter/group are not presented in index than data will be retreived from the table itself. Running query with columns included into the index will use index data only and in this case query will be executed much faster.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.