Write Operation: MongoDB Vs PostgreSQL 9.3 (JSON)

15 May

PostgreSQL 9.3  has lot of new improvement like the addition of new operators for JSON data type in postgreSQL, that prompted me to explore its features for NoSQL capabilities.

MongoDB is one of NoSQL solutions that have gotten a great deal of attention in the NoSQL market. So, this time I thought to do some benchmarking with the NoSQL capability of JSON in MongoDB and the JSON datatype in PostgreSQL 9.3

For this benchmark, I have used the same machine with no optimization in installation of PostgreSQL and MongoDB (since I wanted to see how things work, out of box with default installation). And I used the sample data from MongoDB’s site, around which I had developed the functions which can generate random data using the same sample for Mongo and for PostgreSQL.


In this benchmarking, I have verified following:

1. PostgreSQL COPY Vs Mongo-Import

2. Data Disk Size of PostgreSQL and Mongo for same amount of data.

3. PostgreSQL INSERT Vs Mongo Insert

Some specification before I would display the result:

1. Operating System: CentOS 6.5, 64 bit.

2. Total Memory: 1.538 GB

3. MongoDB version: 2.4.9

4. PostgreSQL: 9.3

Below is the results which I have got:

For Bulkload (COPY Vs MongoImport):

# of rows         1000      10000      100000      1000000
mongo-import (ms) 86.241679 569.761325 6940.837053 68610.69793
PG COPY (ms)      27.36344  176.705094 1769.641917 24801.23291


Disk space utilization:

# of rows        1000      10000     100000      1000000
mongo disks (mb) 208       208       208.2033236 976
pg size (mb)     0.3515625 3.2890625 32.71875    326.8984375


# of Inserts        1000        10000       100000      1000000
MONGO INSERTS (sec) 0.521397404 4.578372454 43.92753611 449.4023542
PG INSERTS (sec)    0.326254529 4.169742939 32.21799302 319.2562722


If you look at above stats, you can see PostgreSQL JSON is much better in bulk loading and INSERTs.

Best thing is that it takes less space than MongoDB and doesn’t eat up much disk space.

11 Responses to “Write Operation: MongoDB Vs PostgreSQL 9.3 (JSON)”

  1. Vikram Rai May 16, 2014 at 17:31 #

    This is good information. Thanks Vibhor! I wonder how the updates are in the comparison

    • Database Technologies May 16, 2014 at 18:05 #

      Thank you Vikram.

      I will be posting benchmark of UPDATE too.
      Till then have patience🙂

      • amihay May 19, 2014 at 10:11 #

        what about queries comparison ?

      • Database Technologies May 19, 2014 at 17:45 #

        In my next blog I will include that. This was kind of quick benchmarking.

  2. Vincent May 19, 2014 at 10:13 #

    It is probably wise to wait with more benchmarking until 9.4 because that promises some serious improvements in the way PgSQL deals with JSON.

    But perhaps more importantly; did you tune both databases for the hardware and the workload? Because in the real work nobody runs untuned databases…. well, most people don’t…. uhm… yeah probably most MySQL and NoSQL users do actually… good point.🙂

    • Database Technologies May 19, 2014 at 17:44 #

      yeah. This benchmark is about, if we don’t tune both Databases,then out of box which performs.

      I am planning to do then benchmarking BSON Vs JSONB (PG). I will post the result soon.

  3. Felipe B May 23, 2014 at 17:42 #

    This is an extremely interesting benchmark. Thanks for doing it and sharing it.

  4. Vladimir Voznesensky October 1, 2014 at 03:50 #

    PG 9.3 scales well when the number of clients grow.


  1. Write Operation: MongoDB Vs PostgreSQL 9.3 (JSON) | Ragnarok Connection - July 16, 2014

    […] Filed under: PostgreSQL 9.3, PPAS, PPAS 9.3 Tagged: EnterpriseDB, MongoDB, PostgreSQL 9.3   Related Article: Database Technologies […]

  2. PostgreSQL ramps up its NoSQL game | 4an Nyheter - August 21, 2014

    […] In that vein, Vibhor Kumar, EnterpriseDB’s principal system engineer, recently produced a set of benchmarks that he believed showed PostgreSQL to be faster and less greedy with disk space than MongoDB for […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: