Slashdot Mirror


PostgreSQL Outperforms MongoDB In New Round of Tests

New submitter RaDag writes: PostgreSQL outperformed MongoDB, the leading document database and NoSQL-only solution provider, on larger workloads than initial performance benchmarks. Performance benchmarks conducted by EnterpriseDB, which released the framework for public scrutiny on GitHub, showed PostgreSQL outperformed MongoDB in selecting, loading and inserting complex document data in key workloads involving 50 million records. This gives developers the freedom to combine structured and unstructured data in a single database with ACID compliance and relational capabilities.

42 of 147 comments (clear)

  1. It doesn't matter by DoofusOfDeath · · Score: 5, Funny

    Because Postgres isn't web-scale. I want web-scale.

    1. Re:It doesn't matter by mwvdlee · · Score: 3, Funny

      "Web-scale" is "big enough to hold a Wordpress database"?

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    2. Re:It doesn't matter by i+kan+reed · · Score: 3, Informative

      I was about to get wooshed, and post something about how "web-scale" isn't any kind of meaningful standard, but then I thought better of it, looked it up, and found it's MongoDB's tagline.

      I can only think of one database that isn't "webscale", and that's TinySQL, which I still use for personal web projects regardless.

    3. Re:It doesn't matter by SQL+Error · · Score: 4, Informative

      Ah, memories. That had us rolling on the floor at my office at the time.

      For those who missed it, or want to relive it: http://www.youtube.com/watch?v...

    4. Re:It doesn't matter by DoofusOfDeath · · Score: 5, Funny

      I'm afraid you were still semi-wooshed. I was actually making a reference to this.

    5. Re:It doesn't matter by Anonymous Coward · · Score: 5, Informative

      the linux kernel doesn't even have to load it into RAM, it goes from disk to network directly.

      Oh really? so your network card is a bus master and can initiate transfers from other peripherals without using DMA?
      I assure you, the Linux kernel still loads the file into RAM. Your RAM is fast compared to SATA or Ethernet, it's an excellent staging ground for such transfers. But obviously you don't need to load the entire file before you start sending it out, there are tricks that let the kernel deal with it by tracking the DMA status of the ethernet card and using memory mapped files.

    6. Re:It doesn't matter by Warbothong · · Score: 5, Funny

      I can only think of one database that isn't "webscale", and that's TinySQL, which I still use for personal web projects regardless.

      I hadn't heard of TinySQL, so I just Googled it. From http://sourceforge.net/project...

      > tinySQL is a SQL engine written in Java.

      Is the name meant to be ironic or something?

    7. Re:It doesn't matter by plopez · · Score: 5, Funny

      "I can only think of one database that isn't "webscale", and that's TinySQL, which I still use for personal web projects regardless."

      You've just made all those MS Access developers cry.....

      --
      putting the 'B' in LGBTQ+
    8. Re:It doesn't matter by astro · · Score: 2

      This comment just made me shudder with the painful memories of writing web applications in Cold Fusion that used ADO to talk to MS Access files as the DB backend in like 1998. Ugh.

    9. Re:It doesn't matter by gwolf · · Score: 4, Informative

      Just adding to what the others have stated: RAM speed is in the vicinty of a million times HDD speed. You won't notice a file going to RAM before being sent to the network interface. Doing all of the kludgework for this to happen (if possible!) would be for a negligible gain.

    10. Re:It doesn't matter by sexconker · · Score: 2

      This comment just made me shudder with the painful memories of writing web applications in Cold Fusion that used ADO to talk to MS Access files as the DB backend in like 1998. Ugh.

      You think that's bad? I was doing this in 2008.
      (First task was to get them the fuck out of access and onto an actual SQL server.)

    11. Re:It doesn't matter by Dragonslicer · · Score: 3, Funny

      two-phase commit

      I'd say just to be safe, you should be using 3- or 4-phase commit.

      Oh yeah? Well my database goes up to 11-phase commit.

    12. Re:It doesn't matter by steelfood · · Score: 3, Funny

      It's a reference to how much data it can hold. The rest of the FS is taken up by the swap file.

      --
      "If a nation expects to be ignorant and free in a state of civilization, it expects what never was and never will be."
  2. "Small" amount of data by ranton · · Score: 5, Interesting

    I am confused. If they are testing the performance of ACID and BASE database systems, why did they use a data load that can easily fit on a single computer? The data size for both databases was under 150 GB which can easily sit on a single hard drive let alone a single server. Why would a BASE database have any edge over an ACID one for a data set that does not require distribution between multiple servers?

    It is still important to see how much faster a more established DBMS is than a relative newcomer for smaller loads, but I still feel this comparison is a bit lacking.

    --
    -- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
    1. Re:"Small" amount of data by Anonymous Coward · · Score: 2, Interesting

      Also, the point of scaling databases horizontally isn't just being able to distribute large amounts of data, but to distribute large amounts of queries.
      I think a lot of people here like to point and laugh at NoSQL and particularly Mongo because they fail to consider the aspect of distributing QUERIES, which is where NoSQL shines compared to *SQL.

      Yes, you can scale sql horizontally, but anyone who doesn't have a deep understanding of the internals of the *SQL engine of choice and has tried to scale them horizontally can testify to what a nightmare it is. At least that is my experience.

    2. Re:"Small" amount of data by Anonymous Coward · · Score: 5, Informative

      Have you used a version of PostgreSQL that is not 10 years old? The vacuum process performs some necessary work asynchronously from your transaction, so that you can have higher concurrency and scalablity. The modern autovacuum does not have locking problems.

    3. Re:"Small" amount of data by Anonymous Coward · · Score: 4, Informative

      Except MongoDB can't do any better!

      "Important notes on compacting:
      "
      "This operation blocks all other database activity when running and should be
      "used only when downtime for your database is acceptable. If you are running
      "a replica set, you can perform compaction on secondaries in order to avoid
      "blocking the primary and use failover to make the primary a secondary before
      "compacting it.

      Source: http://blog.mongolab.com/2014/01/managing-disk-space-in-mongodb/

      The solution in both cases is to mirror your data. I don't know if this particular problem has been solved theoretically, but in any event neither support a compacting vacuum without some write locking. And both support the same workaround.

      NoSQL databases aren't magic. Magic would be asynchronous multi-master replication while maintaining relational integrity, and without any strings attached. No product can do this. Every product has a story, but they either tweak the problem or spin their solution. But that's the state of the art at the moment. We just aren't there, yet.

      If you read the fine print, rather than worshipping with the cargo cultists, you'd know this. Like transactional memory (e.g. lockless data structures), the database field is just filled with misinformation and unrealistic expectations. Developers are clueless. Mostly because no matter what they use, it's going to be fast enough for them. So they're never forced to face their assumptions.

    4. Re:"Small" amount of data by Anonymous Coward · · Score: 3, Interesting

      So, setup replication, yeah it's little more work to do with Postgres than with Mongo, but it's not hard by any means nowadays and you get more flexibility and performance and queries that can actually do things, seem like good deal to me.

    5. Re:"Small" amount of data by bluefoxlucid · · Score: 2

      Actually, the queries in NoSQL document databases are frequently more useful. For example, the atomic FindOneAndModify() search, which can query any set of data--including array values. You can have data that has { PhoneNumber: [5559992332, 5551112234, 5552201212] } and FindOneAndModify({PhoneNumber: 5551112234}, { $pull {PhoneNumber: 5551112234}} ) and delete that specific element from the array.

    6. Re:"Small" amount of data by Aram+Fingal · · Score: 2

      Or even:

      UPDATE table tablename SET PhoneNumber = PhoneNumber - {5551112234}

    7. Re:"Small" amount of data by MobyDisk · · Score: 3, Informative

      Locking up tables for over 30 minutes when they haven't even been updated

      There is no vacuuming on tables that have no updates.

    8. Re:"Small" amount of data by K.+S.+Kyosuke · · Score: 3, Insightful

      Missing WHERE in updates is the rm -rf / advice of the RDBMS world.

      --
      Ezekiel 23:20
  3. The stress-testing wasn't needed by DaCo · · Score: 2

    Anybody who's worked on both already knows that NoSQL-based solutions simply don't live up to the hype.

    --
    DELETE MY ACCOUNT
    1. Re:The stress-testing wasn't needed by Sarten-X · · Score: 4, Insightful

      I've worked extensively on both kinds of systems over the past decade. Under a particular workload that is exactly what an RDBMS is designed for, an RDBMS has the best performance? Wow, who would have bet on that one?

      Then again, I've had workloads (my go-to example is writing several billion records in a matter of hours for statistical analysis, with live intermediate results) where a NoSQL solution had the best performance.

      NoSQL isn't some rebellion against traditional databases. Engineering isn't a contest. Rather, NoSQL, column-stores, distributed warehousing, or any other term you'd like to throw out all just point to an additional option for how to manage your data. Pick the right choice for your project, and use it. Don't worry about "web-scale" or "ACID compliance" talking points unless your project needs them. For the past few decades, we've been forced into the assumption that data must perfectly normalized, arranged in tables, and must be queried as relations. For some projects, massaging the data into that form will damage your performance far more than your database engine ever will, so a different engine makes a better choice.

      Stop listening to hype, deserved or not, and use the right tool for the job.

      --
      You do not have a moral or legal right to do absolutely anything you want.
    2. Re:The stress-testing wasn't needed by badboy_tw2002 · · Score: 4, Funny

      "Engineering isn't a contest."

      But...but...I have a hammer. I KNOW how to use a hammer. A hammer is the best! FUCK YOU SCREW! TAKE THAT SCREW! Job complete!

    3. Re:The stress-testing wasn't needed by Required+Snark · · Score: 2
      You forgot a crucial point, this is Slashdot. When you said "Engineering isn't a contest" you violated the Way of Slashdot.

      On Slashdot, it's all about people with deeply held irrational opinions who make unsupportable claims. Additionally, they express themselves in rants and slander, and rational discourse is considered a sign of weakness. If you want to find people who think, you're in the wrong place.

      --
      Why is Snark Required?
  4. I dipped my toe in MongoDB by EmperorOfCanada · · Score: 4, Interesting

    I tried MongoDB and I even tried to like it. I do love NoSQL but what I came to realize was that MongoDB was trying to tell me how to solve my problems instead of just storing my damned data.

    But the real problem with MongoDB was that nearly everything, while appearing simple, required a google search to figure out how to do it. A mark of a very well designed API is that you soon start guessing the commands and your guesses are really close or right on. But with MongoDB I found that nothing really made sense. Only after carefully crafted "debate team" arguments could any unusual aspect of MongoDB defend itself. Whereas redis is the opposite, it just works. Or even simpler systems like Memcache, that couldn't be simpler, when read the API for either of those they just made sense. There is no layer upon layer upon layer of complexity. It is data goes in, and data comes out.

    In fact redis would be a good example of ease of use mixed with advanced capabilities. The basic commands are things like get, append, save, while more advanced commands are more esoteric such as PEXPIREAT which has to do with timestamp expiries. So you can happily use redis like a simple minded fool and it is wonderful. Or you can dig in deeper and only mildly shake your head at some of the command names. But with MongoDB it is just a pain in the ass from the first moment you truly have even vaguely complicated data.

    But back to PostgresSQL. The JSON related features are mildly complex but appear to be solving the most common problems. Also by using PostgresSQL it solves the entire debate of relational vs NoSQL. Use PostgresSQL and you can just do both without giving it a second thought. And I for one can certainly say that I have data that demands NoSQL and I have other data that demands relational; all in the same project. But oddly enough the technique that I use is MariaDB for the relational and redis for everything else. This is ideal for me as the relational data is very simple and won't need to scale much whereas the redis stuff needs to run at rocket speeds and will be the first to scale to many machines.

    But as for MongoDB, it has been deleted from all machines, development and deployment and will never be revisited regardless of this weeks propaganda.

  5. The tipping point by tyggna · · Score: 4, Informative

    I've done research against these database programs, and this is really really old news for anyone who has done testing. If you have a single machine, then Oracle is the best performing database, followed by Postgres. When you need more than 4 dedicated servers hosting a database, then mongo can handle about 180% of the volume that oracle can, and about 220% the volume of postgres, and about 110% the volume of Casandra.
    As soon as you need more than one machine to host your database (which usually happens around 1000 active users on your website at any given time, depending on your application), consider switching off of an SQL database.

    1. Re:The tipping point by CastrTroy · · Score: 3, Informative

      Unfortunately is often very difficult to switch database engines, especially if you are switching to NoSQL. I've been on one project where we switched from SQL Server to MySQL, and it didn't go too bad, but that's because the majority of the SQL in the project was standard select, insert, updates and deletes. Had there been a lot of stored procedures, or use of other non-standard SQL the project would have probably taken a lot longer to accomplish.

      --

      Anthropic principle: We see the universe the way it is because if it were different we would not be here to see it.
    2. Re:The tipping point by MillerHighLife21 · · Score: 2

      Have you seen Postgres-XC? It's pretty much built for this purpose.

      http://postgresxc.wikia.com/wi...

      --
      "Don't teach a man to fish, feed yourself. He's a grown man. Fishing's not that hard." - Ron Swanson
    3. Re:The tipping point by Just+Some+Guy · · Score: 2

      If you have a single machine, then Oracle is the best performing database, followed by Postgres. When you need more than 4 dedicated servers hosting a database, then mongo can handle about 180% of the volume that oracle can, and about 220% the volume of postgres, and about 110% the volume of Casandra.

      This, this, a million times this. A recent employer needed to be able to sustain 250,000 inserts per second. Not 24/7, mind you, but at random prolonged intervals throughout the day. The "PostgreSQL is the fast" chart shows it handling 10,600 bulk load operations per second or 1,700 individual inserts per second. That would be about 1/150th of the insert load we needed to handle.

      I'm a huge fan of PostgreSQL - when it's appropriate. If you need strong relational and consistency guarantees, there's nothing I'd recommend over it. But sometimes you just need to move enormous amounts of data around very, very quickly. That's the use case where various NoSQL stores suddenly become very attractive. We chose Cassandra here because its big-O algorithmic complexity matched up very nicely with our access patterns, being O(1) where we needed it to be and O(n^2) where we couldn't care less.

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:The tipping point by Per+Wigren · · Score: 3, Informative

      Postgres-XC's main focus is OLTP workloads. Buzzword: Web Scale.
      Postgres-XL's main focus is OLAP workloads. Buzzword: Big Data.
      They both borrow code from each other. At some time in the future it's entirely possible that the two will merge.

      --
      My other account has a 3-digit UID.
  6. The best one. Ah. by Anonymous Coward · · Score: 2, Interesting

    "MongoDB, the leading document database and NoSQL-only solution provider,"

    According to who?
    What happened to all the rest of them, like CouchBase or Riak?

    I will admit bias, though. I like my db's eventually consistent.

  7. No news! by aglider · · Score: 2

    Whoever did serious performance tests against PostgreSQL already knew!

    --
    Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
  8. Re:what are the MEAN hipster coders going to do no by Anonymous Coward · · Score: 3, Insightful

    Anything but read a computer science textbook

  9. Still goes into RAM by Chirs · · Score: 2

    Even when using sendfile() in linux, the disk does a DMA transfer into RAM, and the NIC does a DMA transfer out of RAM.

    While the CPU is not involved in copying the data, it still goes into RAM.

  10. Re:Replication anyone? by Anonymous Coward · · Score: 5, Funny

    Can PostgreSQL do replication? Not really.

    That's news to me, I guess the data on our read servers just magically appear and what more magically appear to be the same data we need there.

  11. Not surprising... by rgbatduke · · Score: 5, Interesting

    ... because of the way MongoDB actually stores records and parses them. It is more or less a simple tree or linked list, and hence doing almost anything involves decending branches to the leaves. This is horrendously inefficient in many contexts, while still being perfectly lovely in others. Just doing a match, though, can involve a non-polynomial time search. Maybe they've improved this from when I was trying to use Mongo to drive modelling, but I doubt it as it would have involved substantially changing the way the data is actually stored and dereferenced. I had to cheat substantially in order to get anything like decent performance, and any of the SQLs outperformed it handily.

    Note well that it was strictly a scaling issue. For small trees and DBs, it probably works well enough. For large DBs with millions of records and substantial structure, it is like molasses. Only worse.

    rgb

    --
    Even when the experts all agree, they may well be mistaken. --- Bertrand Russell.
  12. The tipping point by n1ywb · · Score: 2

    My understanding is that it's easy to spread READ ONLY postgres load accross multiple servers. WRITING is a bottleneck with postgresql though because it enforces consistency, while other DBs like couch kick the consistency can down the road to the application. But I haven't seriously looked into it in years.

    --
    -73, de n1ywb
    www.n1ywb.com
  13. Could that chart suck more? by Just+Some+Guy · · Score: 2

    Look at the "MongoDB 2.4/PostgreSQL 9.4 Relative Performance Comparison" and see that MongoDB's bars are much higher than PostgreSQL's, with labels like "276%" and "465%". That looks like MongoDB is much better, right? Oh, oops! Apparently that's how much slower MongoDB is.

    --
    Dewey, what part of this looks like authorities should be involved?
  14. Re:Replication anyone? by cdwiegand · · Score: 2

    Can MongoDB do master-master replication? Oh, it's can't, and really only CouchDB does in the NoSQL space? Oh, that's too bad. Of course, most of us don't NEED M-M replication, as it introduces serious issues with reliability (oh I wrote the client record to server A and then queried server B on the next page load and it didn't exist yet -> Null Exception #AWESOME!) and is only useful for backups/reporting/import/export scenarios. The rest of us who actually want to GET WORK DONE will probably continue with relational DBs and post JSON documents as needed into our databases (e.g. json doc for lists/complex objects where we don't want/care to index any fields within).

    And ACID doesn't fall apart at all in sharding - what are you smoking?? You implement a standard sharding scheme and the same record always goes to the same server. NoSQL doesn't do a thing for sharing... Replication is a problem, but it is for NoSQL too.

    --
    . Define sqrt(x) as something really evil like (x / rand()), and bury it deep. Watch your coworkers go nuts.
  15. Re:You forgot SQLite by gman003 · · Score: 2

    The performance degrades (or at least, doesn't scale well) once you have multiple processes accessing the same database, as you would be on a web server. It's a great tool, don't get me wrong, and I can definitely see the use case for a test environment. But even on a single-server system, you're better off with an actual database process.