PostgreSQL vs MySQL vs MariaDB - Help me Decide
PostgreSQL & MySQL are the two most popular open-source databases today.
The less popular MariaDB is a MySQL fork that happened after the acquisition of Sun Microsystems by Oracle on January 27, 2010.
Here's a graph representing the popularity of these 3 databases:
PostgreSQL & MariaDB have been gaining ground recently, while MySQL is slowly declining. But that's not enough to make a decision.
So which one should you choose?
Let's look at this from different angles.
By running some benchmarks you can get a rough idea of how these databases compare to each other in terms of performance.
For this article, we going to use the HammerDB benchmarking tool.
This tool implements a standardized performance test called TPC-C.
Here's the description:
"TPC-C involves a mix of five concurrent transactions of different types and complexity. The database is comprised of nine types of tables with a wide range of record and population sizes."
Here's the setup:
- Ubuntu 18.04
- 1 GB RAM
- 1 CPU
- MySQL 5.7.23
- MariaDB 10.1
- PostgreSQL 10.5
- Default settings
We ran the tests for 5 minutes for each database.
Here are the results:
- PostgreSQL 18534 TPM, 7972 NOPM
- MySQL 14051 TPM, 4659 NOPM
- MariaDB 21441 TPM, 7172 NOPM
The meaning of these two values (TMP & NOPM) is described like this:
"TPM values cannot be compared between different database types. The NOPM value is based on a metric captured from within the test schema itself. As such NOPM (New Orders Per Minute) is a performance metric independent of any particular database implementation and is the recommended primary metric to use."
Like any benchmark the results depend on the specific scenario the tests are run in.
This particular benchmark tries to reproduce the workload of any industry that must manage, sell or distribute a product or service.
Knowing that, we can conclude that both PostgreSQL & MariaDB are faster than MySQL in this particular scenario, with PostgreSQL coming on top of the raw performance game.
These 3 databases support all the basic SQL operations you would expect.
But when it comes to more advanced features there is a lot of variability between them.
For example, PostgreSQL supports materialized views, while MySQL doesn't.
Here's a feature comparison table:
|Array Data Type||✓||✖||✖|
|JSON Data Type||✓||✓||✓|
|CHECK constraints||✓||✖||✓ (from version 10.2.1)|
|Common Table Expressions||✓||✓||✓|
Looking at this table we can conclude that PostgreSQL has the most features implemented.
Besides these features, you can find some behavior differences.
For example, this query:
NULL in MySQL, while PostgreSQL & MariaDB (since version 10.2.4) return a division by zero error.
This can be changed with SQL modes in MySQL.
Administration & Monitoring Tools
Because databases are critical software components there are dozens of tools available for administration, monitoring & troubleshooting.
Starting with the command-line applications:
These are great for basic administration tasks.
Because they come built-in with their respective servers so they are always available. There is nothing extra to install.
They both have a command history available, so you can re-run previously executed queries & commands.
And they have a set of bult-in commands that can facilitate interacting with the database.
psql has the
\d command to list all your databases, and
mysql has the
status command to get information like the server version & uptime.
Official graphical tools are also available.
Here's a screenshot from pgAdmin4:
And for MySQL Workbench:
Now we move onto more specialized tools like pghero (PostgreSQL).
PgHero is "a performance dashboard for Postgres".
Here's a screenshot:
For MySQL, and MariaDB, you can use MySQL Tuner. This is a Perl script that will analyze your configuration file & database statistics to produce configuration recommendations.
Here's a screenshot:
There are also log-parsing tools to help you find slow queries.
Here's pt-query-digest for MySQL, a tool for analyzing your logs & running queries to find the slowest queries so you can optimize them.
As you can see in this screen, it's also a command-line tool:
And here is pgBadger for PostgreSQL:
pgBadger is like pt-query-digest, but it will analyze PostgreSQL logs & slowest queries.
It looks like PostgreSQL has more graphical tools available, so if you are more comfortable using tools with graphical frontends, instead of command-line applications, then you may want to keep this in mind when making your decision.
You can install plugins & extensions if you need extra features for your database.
Extending MySQL & MariaDB is mostly done in the form of UDFs (User-Defined Functions), which are small plugins written in C.
However, it doesn't seem to be a very popular feature, so it's hard to find any useful UDF extensions.
PostgreSQL has some helpful extensions:
- PostGIS adds spatial search capabilities for geographic information systems (GIS)
- HStore allows you to use key-value storage without having to install a specialized database
- Multicorn allows you to query other sources of data (like Redis, Amazon S3, or even Twitter!) as if they were real tables
If you need any of these extensions then PostgreSQL might be a great choice for you.
To make a good decision you should consider what your needs are.
- Is your application going to do a lot of work with geographic information? Then the PostGIS extension would be of great help.
- Could your application benefit from specific features that each database supports, like materialized views or partial indexes? Then choose that database.
- Do you need more hosting & support options? Then MySQL or MariaDB may be a better fit.
We hope you found this comparison useful!
I'm planning to build a freelance marketplace website, using tools like Next.js, Firebase Authentication, Node.js, but I need to know which type of database is suitable with performance and powerful features. I'm trying to figure out what the best stack is for this project. If anyone has advice please, I’d love to hear more details. Thanks.
Postgres and MySQL are very similar, but Mongo has differences in terms of storage type and the CAP theorem. For your requirement, I prefer Postgres (or MySQL) over MongoDB. Mongo gives you no schema which is not always good. on the other hand, it is more common in NodeJS community, so you may find more articles about Node-Mongo stuff. I suggest to stay with RDBMS if possible.
We have a ready-made engine for the online exchange and marketplace. To customize it, you only need to know sql. Connecting any database is not a problem. https://falconspace.site/list/solutions
For learning purposes, I am trying to design a dashboard that displays the total revenue from all connected webshops/marketplaces, displaying incoming orders, total orders, etc.
So I will need to get the data (using Node backend) from the Shopify and marketplace APIs, storing this in the database, and get the data from the back end.
My question is:
What kind of database should I use? Is MongoDB fine for storing this kind of data? Or should I go with a SQL database?
Postgres is a solid database with a promising background. In the relational side of database design, I see Postgres as an absolute; Now the arguments and conflicts come in when talking about NoSQL data types. The truth is jsonb in Postgres is efficient and gives a good performance and storage. In a comparison with MongoDB with the same resources (such as RAM and CPU) with better tools and community, I think you should go for Postgres and use jsonb for some of the data. All in all, don't use a NoSQL database just cause you have the data type matching this tech, have both SQL and NoSQL at the same time.
I have found MongoDB easier to work with. Postgres and SQL in general, in my experience, is harder to work with. While Postgres does provide data consistency, MongoDB provides flexibility. I've found the MongoDB ecosystem to be really great with a good community. I've worked with MongoDB in production and it's been great. I really like the aggregation system and using query operators such as $in, $pull, $push.
While my opinion may be unpopular, I have found MongoDB really great for relational data, using aggregations from a code perspective. In general, data types are also more flexible with MongoDB.
I will use PostgreSQL because you have more powerfull feature for data agregation and views (the raw data from shopify and others could be stored as is) and then use views to produce diff. kind of reports unless you wanna create those aggregations/views in nodejs code. HTH
I want to store the data retrieved from multiple APIs and perform some analytics on it. The data stored in DB will never/hardly change. First, I thought it would be better to retrieve the data and create table columns for them, but some data might have different columns than others. So I thought about storing the JSON response from API directly to the table and use it. So which database will be the better choice, PostgreSQL or MongoDB.
Hey Krunal, your requirement sounds pretty clear and specific to what you want to do with that data. My recommendation to you, would be to use MongoDB. Since schema-less IO is faster in MongoDB, your general speed of reading / writing from and to the database would be quick. Additionally, the aggregate framework is very powerful with large data so that is also something that you can use in computing your analytics.
I suggest you to go with
MongoDB, because it is schema-less, i.e., it permits you to easily manipulate the schema of a table. If you want to add a column, it can be done without much effort. Moreover,
MongoDB can deal with more types of data, since the latest is stored as key-value pair. I do not what kind of analysis you are going to do, but
NoSQL is not the best choice if you are going to use complex queries. In addition, if you are working with huge amount of data and you are interested in optimising the performance, I suggest you
Since you are speaking about API and JSON, I guess that you may using
Node JS for fetching API. I suggest you to try
Mongoose, which facilitate the use of
Looks like the use case is to store JSON data. mongoDB and Postgres differ in so many aspects like scaling and consistency. Postgres has excellent JSON support now with the power of SQL. MongoDB is good in handling schema less data. However in this case it seems these differences don’t matter that much. I’d recommend you go with what you are most comfortable with.
This is largely a matter of opinion. I see that someone else responded and recommended MongoDB but since you are doing data analytics, I highly recommend you go with SQL. You're going to have a really hard time normalizing the data when you can't manipulate relationships and bulk edit with a nice update query.
I'm much more experienced with MySQL than any other database and I am having a hard time getting on board with noSQL entirely because it's really hard to query complex data with relationships using noSQL. I'm using Firestore with one of my apps and MongoDB with another app but they both use MySQL for the heavy lifting and then a document database for things like permissions, caching, etc.
It sounds like the type of problem you need to reverse engineer. I'm sure you can imagine what the data sets would look like if you use MongoDB or Postgres. I suspect that putting in a little bit more work up front will pay high dividends and productivity once the data is normalized.
Again - it's largely a matter of preference but I prefer SQL almost every time.
I don't have an unquestionable opinion regarding your use case. I only trend to pick the MongoDB since it is schemaless avoiding null columns that you not always know when it is used (it depends on the source of the data). The only drawback that I could consider is the query's complexity in MongoDB, sometimes it is a bit tricky, when compared to the traditional SQL queries.
MongoDB's document-oriented paradigm is nicely suited to the results of our ML model. We felt that this compatibility offered some time savings on figuring out and implementing an extensive data formatting and processing system. MongoDB's flexible schemas schemas (due to it being non-relational) were also attractive as a source of additional agility for our development process. The MongoDB ecosystem also has great GUI tools to simplify testing.
- Considering that our main app functionality involves data processing, we chose
Pythonas the programming language because it offers many powerful math libraries for data-related tasks. We will use
Flaskfor the server due to its good integration with Python. We will use a relational database because it has good performance and we are mostly dealing with CSV files that have a fixed structure. We originally chose
SQLite, but after realizing the limitations of file-based databases, we decided to switch to
PostgreSQL, which has better compatibility with our hosting service,
I try to follow an 80/20 distribution when it comes to my choice of tools. This means my stack consists of about 80% software I already know well, but I do allow myself 20% of the stack to explore tech I have less experience with.
The exact ratio is not what’s important here, it’s more the fact that you should lean towards using proven technologies.
I wrote more about this on my blog post on Choosing Boring Technology: https://panelbear.com/blog/boring-tech/
Sign up to add or upvote prosMake informed product decisions
Sign up to add or upvote consMake informed product decisions
What is MariaDB?
What is MySQL?
Need advice about which tool to choose?Ask the StackShare community!
Sign up to get full access to all the companiesMake informed product decisions
Sign up to get full access to all the tool integrationsMake informed product decisions
MySQL was founded by Allan Larsson, Michael Widenius and David Axmark in the year 1995, 19 years ago. It was released under the name of co-founder Michael Widenius daughter, ‘My‘. This project was released under GNU General Public License as well as under certain Proprietary License. MySQL was owned by MySQL AB firm until it went into the hands of Oracle Corporation. It is written in Programming Language – C and C++ and is available for Windows, Linux, Solaris, MacOS and FreeBSD.
In the year 2009, Michael Widenius started working on MarisDB as a fork of MySQL. In the year 2012 the bricks of nonprofit MariaDB Foundation was laid. It was named after the founder’s daughter Maria.
MariaDB is a fork of MySQL Relational Database Management System which again is released under GNU General Public License. It is written in Programming Language – C, C++, Perl and Bash and is available for Systems Linux, Windows, Solaris, MacOS and FreeBSD.
We use postgresql for the merge between sql/nosql. A lot of our data is unstructured JSON, or JSON that is currently in flux due to some MVP/interation processes that are going on. PostgreSQL gives the capability to do this.
At the moment PostgreSQL on amazon is only at 9.5 which is one minor version down from support for document fragment updates which is something that we are waiting for. However, that may be some ways away.
Other than that, we are using PostgreSQL as our main SQL store as a replacement for all the MSSQL databases that we have. Not only does it have great support through RDS (small ops team), but it also has some great ways for us to migrate off RDS to managed EC2 instances down the line if we need to.
PostgreSQL combines the best aspects of traditional SQL databases such as reliability, consistent performance, transactions, querying power, etc. with the flexibility of schemaless noSQL systems that are all the rage these days. Through the powerful JSON column types and indexes, you can now have your cake and eat it too! PostgreSQL may seem a bit arcane and old fashioned at first, but the developers have clearly shown that they understand databases and the storage trends better than almost anyone else. It definitely deserves to be part of everyone's toolbox; when you find yourself needing rock solid performance, operational simplicity and reliability, reach for PostgresQL.
Relational data stores solve a lot of problems reasonably well. Postgres has some data types that are really handy such as spatial, json, and a plethora of useful dates and integers. It has good availability of indexing solutions, and is well-supported for both custom modifications as well as hosting options (I like Amazon's Postgres for RDS). I use HoneySQL for Clojure as a composable AST that translates reliably to SQL. I typically use JDBC on Clojure, usually via org.clojure/java.jdbc.
We are used MySQL database to build the Online Food Ordering System
- Its best support normalization and all joins ( Restaurant details & Ordering, customer management, food menu, order transaction & food delivery).
- Best for performance and structured the data.
- Its help to stored the instant updates received from food delivery app ( update the real-time driver GPS location).
1.It's very popular. Heared about it in Database class 2. The most comprehensive set of advanced features, management tools and technical support to achieve the highest levels of MySQL scalability, security, reliability, and uptime. 3. MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language.
We use MySQL and variants thereof to store the data for our projects such as the community. MySQL being a well established product means that support is available whenever it is required along with an extensive list of support articles all over the web for diagnosing issues. Variants are also used where needed when, for example, better performance is needed.
PostgreSQL is responsible for nearly all data storage, validation and integrity. We leverage constraints, functions and custom extensions to ensure we have only one source of truth for our data access rules and that those rules live as close to the data as possible. Call us crazy, but ORMs only lead to ruin and despair.
MySQL is a freely available open source Relational Database Management System (RDBMS) that uses Structured Query Language (SQL). SQL is the most popular language for adding, accessing and managing content in a database. It is most noted for its quick processing, proven reliability, ease and flexibility of use.
Tried MongoDB - early euphoria - later dread. Tried MySQL - not bad at all. Found PostgreSQL - will never go back. So much support for this it should be your first choice. Simple local (free) installation, and one-click setup in Heroku - lots of options in terms of pricing/performance combinations.
I am not using this DB for blog posts or data stored on the site. I am using to track IP addresses and fully qualified domain names of attacker machines that either posted spam on my website, pig flooded me, or had more that a certain number of failed SSH attempts.
Aside from Redis, we use MariaDB to store long-term information like user-data and big-data like regeneration-information for our open-world servers. We extensively use the relational aspects of MariaDB in joins, nested queries and unions.
mysql보다 mariaDB가 join면에서 우수하다는 문서를 읽었습니다. 이 부분은 저의 블로그에서도 다뤘고 저의 word press 블로그는 mysql 대신 mariaDB 를 사용합니다.
특히 limit 기능이 pagenation 처리를 할 때 너무 직관적이고 편해서 mariaDB, mysql을 사랑합니다.
Introduced in computer science course.managing relational database management systems, database analytics, and for data processing
수 백만개가 넘는 태그 키워드의 자동완성을 위해서 별도의 데이터베이스를 구축하였습니다. MariaDB 는 MySQL 을 포크한 프로젝트입니다. MySQL 과의 강력한 호환성을 지니며, 큰 튜닝 없이 강력한 성능을 보장합니다.