I am doing some performance tests between SQL Server 2012 and MongoDB 2.4.9. I have done a little research online and found many comparisons that compare only insert performance between these two databases. I am only interested in select
performance without indexes. I setup a very simple test. Here are the specs
SQL Server setup
MongoDB setup
When I inserted the numbers they are the exact same numbers going into both databases. The random numbers range from 1 to 1000.
SQL Server query
select id from a101 where id > 995
MongoDB query
var q = Query.GT("id1", 995);
foreach (var i in collection.Find(q))
{
values.Add(i.id1);
}
Results:
For my schema I will not need any joins and will have only denormalized data - this is why I considered MongoDB. I expected mongoDB to be many times faster than SQL Server after reading the benchmarks online. Is there something I may be doing wrong? Again, I wanted to test without indexes.
MongoDB is likely five times slower in this case because it needs to read and output five times as much data.
One row in your SQL table is just 4 byte. But in MongoDB it is a 4 byte integer plus a 12 byte ObjectId. Also, the field-names are part of each individual document. The strings _id
and id1
are part of each document you retrieve, so some additional bytes are added.
And this is just the actual payload. When you look at BSONSpec.org you can see that your document is represented by:
0x01
for "now comes an ObjectId"_id
0x10
for "now comes a 32bit integer" (smallest integer there is)id1
0x00
which marks the end of the documentwhich is a total of 31 byte.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With