Why I Choose PostgreSQL Over MySQL/MariaDB
Nerval's Lobster writes For the past ten years, developers and tech pros have made a game of comparing MySQL and PostgreSQL, with the latter seen by many as technically superior. Those who support PostgreSQL argue that its standards support and ACID compliance outweighs MySQL's speed. But MySQL remains popular thanks to its inclusion in every Linux Web hosting package, meaning that a mind-boggling number of Web developers have used it. In a new article, developer David Bolton compares MySQL/MariaDB 5.7.6 (released March 9, 2015) with PostgreSQL 9.4.1 and thinks the latter remains superior on several fronts, including subqueries, JSON support, and better licensing and data integrity: "I think MySQL has done a great job of improving itself to keep relevant, but I have to confess to favoring PostgreSQL."
Best of all worlds. And guess what, in the grand scheme of things, the price is a drop in the bucket compared to salaries.
Who trusts MySQL with important data? No one who knows about PG. Good web frameworks like Django prefer PG, while crap ones like Drupal and other PHPtards prefer MySQL.
It's not Access
Let me quote, from the comments thread at a recent article by same submitter:
Another user, in the same thread, had speculated:
No, sir, you were utterly wrong. It came "Postgresql is better than Mysql".
MS SQL Server is for 3rd world lamers. Macho PHBs demand Oracle!
I use MySQL/MariaDB mostly out of inertia. When I started working on websites, MySQL was typically the default software available. When I went on to set up my own websites and various other projects I continued to use MySQL out of habit, it was what I knew. Today I continue to use MySQL/MariaDB, mostly because I've never needed to do anything that it did not do well.
I have heard about corner cases where other databases perform better are behave in a "more correct" way, but none of those cases has ever been relevant to me, so I continue to happily use MySQL.
We don't care that you're different. Must be a soft news day at Slashdot... Oh wait. It's always a slow news day at Slashdot.
Buck Feta. You know what to do.
And for many tasks, you don't need any of that. Have a look at SQLite3 (also, it's built into Python, which can be handy.)
Worried about stability? You can compile the SQLite3 source code right into your project. That way, your databases always match your shipping product, indefinitely, period.
It's not usable for everything -- only a decent subset of SQL is supported -- but you might be surprised at just how much is there, and working well.
I've fallen off your lawn, and I can't get up.
I come from a Sybase SQL Anywhere shop. It never ceases to amaze me how stuff that can be elegantly expressed in a couple of queries in Watcom-SQL typically takes four times as much code in MySQL's dialect. I love Sybase's support for the ANSI standards, subqueries, Java/.NET/C/PHP/Perl stored procedures when they are the right tool for the job (ever needed to resize raster images in an INSERT trigger coming from some third-party application?), and great drivers. I shouldn't have to spend 10 minutes trying to figure out why MySQL doesn't support the standard casting string concatenation operator by default (||), or why subqueries don't work like they ought, etc.
Having used Postgres, all of the worthwhile MySQL features are there, most of the SQLA features are there, and the pain level is much, much lower in Postgres than MySQL for someone coming from a full-featured commercial RDBMS.
What really sucks is all of the applications that are so coded around MySQLisms that they don't run on ANSI-compliant engines.
Show us on the doll where "open sores" touched your micro-soft and gave you this raging case of bs.
I just need a database to hold crap, I don't care about it being 1 nanoseconds faster.
Isn't everyone all NoSQL nowadays or has that faded away?
I'm god, but it's a bit of a drag really...
Don't even bother, you can pretty much identify him on every post lately
One expression I remember seeing on the topic went something like: "I can make it as fast as you want as long as it does not have to actually work". The conversation was about filesystems comparing (the non-complying) async-mode with the safer (but slower) alternatives, that actually stood by the promise of fsync(2).
And another, more modern idea (only about 10 years old) quote is "Object/Relational Mapping is the Vietnam of Computer Science". Which, for the purposes of TFA, may be interpreted as something like "who cares for ACID compliance — we can deal with occasional data-corruption and inconsistencies — just make it fast in the usual case".
I rather doubt, we'll settle the question in this discussion...
In Soviet Washington the swamp drains you.
pgAdmin is terrible
This is news, but the only thing to discuss is other use cases (problems already solved) or no use cases in which we all go into armchair mode and have endless debates already hashed out a million times over.
I'm not quite sure about that but I though that not even MySQL's InnoDB allows you to alter your DB schema "under full throttle", whereas databases like PostgreSQL or Firebird shouldn't really have problems with that - transactions up to n see the old schema, transactions from n+1 onwards see the new one, and the RDBMS insulates you from all the nasty bookkeeping. I'm mentioning this as a post scriptum to the "Table Changes Without Locking" feature which is really 1980s stuff. (True, for Firebird, even table structure altering without locking is 1980s stuff, but that would be a low blow for MySQL. ;-))
Ezekiel 23:20
The MOST important reason for using Postgres is that it has object ids (OIDs). This allows true referential integrity. You can have a row point at another row and this reference stays the same REGARDLESS of whether you change the primary key of the referenced row. This allows true object orientation.
What about Firebird? It's a fully featured RDBMS with a fair bit of performance.
I dare say it beats MySQL on almost every front. Mostly popular on Windows with the Delphi crowd.
Are these stories *ever* going to mention that Dice is /.'s parent company?
And I'm probably going to step on a lot of toes here, but people like me strongly prefer Postgres to MySQL. And by "people like me" I mean folks for whom their first real rdbms experience was theoretical or "commercial". I did both.
I used ingres in college to a small extent and then the Ingres commercial product for years after that. I have also used Sybase and Oracle professionally. PostgreSQL easily walks among the giants of that industry.
Every time this discussion comes up the MySQL side has to say "yeah, but..." about a thousand times. MySQL doesn't do ______ properly? "Yeah, but if you just install this other piece of software and change a couple of config files it *can* do it.' Well, con-fucking-gratulations!
The point is that PostgreSQL does exactly what it should do out of the box. I don't have to change a configuration file to make it ACID compliant, fast, correct, whatever. It just works and works correctly out of the box.
Every time someone tells me how easy MySQL is to set up they've betrayed their experience level in this realm.
I know a lot of you are going to mod me down - I don't care. But why not reply instead?
Do you have ESP?
The summary is a lie. If you don't like MySQL then just don't use it. Don't bash it by making-up lies.
We have a lot of XML publishing workflows. MySQL provides a -X commandline option which returns the results of a query in XML. I don't know if PostgreSQL, MSSQL, or Oracle have the equivalent (perhaps someone who knows can post). Right now, it's a pain-free way to get what we need in the form we want, with zero additional effort. If it exists in other rDBMSs, that makes our choices wider.
Chances are, you don't know anything about databases. JetProfiler will show you the crappy queries you're using in an easy-to-understand way so you can fix your stuff and make everything faster.
AFAIK, no such tool exists for Postgresql.
As a bonus you don't have to deal with the annoying psql/pgsql crap, which for some reason drives me bonkers. I mean come on, make it psql or pgsql, not both. WTF?
For anything that matters you use Oracle, for everything else you can use whatever the hell you want
In the beginning, Postgress set out with correctness as the primary goal. Whatever it did, it had to do it correctly. It started life on the slow and resource hungry side. MySQL set out to be fast and more or less correct in the common case. Back in the '90s that made a lot of sense for small servers.
In the decades since, servers have gotten bigger and Postgress got fast and efficient while still being correct. Why would I want to incur a performance penalty in the surrounding software to check behind the database to make sure it didn't just scrag my data?
Come on - who really cares about MIT versus GPL licensing in this context? And by "who" I mean "people who manage and use databases as part of their paid job"?
And why does anyone care what someone writing for Dice says on this topic? I read the article, and it doesn't sound like the author has even used any of the features he's decided favor postgres.
What's next - a Dice article on emacs vs. vi?
#DeleteChrome
So we all agree that Postgres is better, ok? Now let me get back to my MySQL database which has all those features poorly implemented but is easy to use and does exactly what I want.
I haven't -- I've seen cases where the filesystem corrupted itself (with or without the help of hardware failure, no idea), but I've used SQLite most extensively (seriously, I bet I'm close to having used every feature in the thing) in its various revisions for years, as have tens of thousands of my users consequent to my incorporation of same, and I've heard of, and experienced, exactly zero events of DB failure (and one of my most popular apps would have crapped itself and gone blind if such happened, so I'd surely have heard about it.)
Also, different app (SdrDx), but I use it the other way around here; I've got an SQLite DB on my website that tracks startups of the code as to version, revision, step, beta status, platform (windows, OSX), time, date and IP, as part of the handshake that lets the users know if there are any upgrades (in-app title bar notification, nothing invasive.) This lets me keep track, somewhat, how many people are using what version of the app. SdrDx is well over 15 thousand regular users, many more that aren't regular, and the DB is moderately busy as a result, again, no problems. The writes to this particular DB are pretty straightforward, but the queries I've written for it span a decent range of futzing about. No problems to date. Of course it's backed up, but no need for a backup as yet.
I'm also presently using it, again extensively, in an incomplete, but complete enough for my day to day use, DSLR application of mine, code compiled in, along the lines of Lightroom and Aperture, and again, zero DB failures of any kind. Oodles of DB activity for every image, every library op, every bit of auto-categorizing, library backup, tagging, annotating, posted-to recording, flagging, versioning, plug-in and plug-in settings recording, and so on.
So I'm going to go with... possible, but even slightly likely. Also, any DB can take a crap if the drive underneath it goes bad, or the OS (or some all too clever use of root privs) allows corruption of its storage. None of which should be construed as any kind of criticism of any DB engine subject to the same.
Also, did you report these purported corruption events to the author of SQLite? Sure hope you did. :/
I've fallen off your lawn, and I can't get up.
With the last iteration adding JsonB build a MVC with PLV8 is a no brainer, Fast and robust development!
postgreSQL + PLV8 + JSONB + NodeJS
Gimme something with krb5 auth.
If you don't care about your data, and don't mind it getting corrupted every few years, put it in mysql or a fork of it. I've seen it time and again over the last 15 years clobber data at various employers. Developers use that hobbyist grade toy because they don't know any better, it's what they played with on their pc so they use it at work.
You chose Itanic? Really? And your dedicated 1MWatt power plant is located where?
Can't tell the difference between a programming framework and a web blog. How "Interesting".
As long as a database engine has stored procedures and a decent client binding library, I can make it go. I've worked with MySQL, SAP/Sybase ASE, DB/2 LUW, PostgreSQL, Oracle, and SQL Server extensively over the years. There comes a point where you just know enough about the quircks and foibles of each of the databases to get around their particular issues and "just make it go."
People who bitch about the minor syntactic differences between the vendors clearly haven't really ported an application, because the differences in behaviour go far beyond syntactic sugar. Despite the ANSI standards, you can't just install the schema on a competitor's database and expect it to run an application properly without a lot of rework and restructuring.
Sure your basic table structures may remain compatible, but that's about it.
Every vendor has at least a few features that encourage "lock-in" by being incompatible with all their competitor's products.
I do have a rule about which databases I work with, though: if it doesn't have stored procedures, I won't use it. The performance benefits of complex stored procedures vs. logic in the client is just too dramatic to ignore and gloss over. Not to mention the fact that coding the logic in the client application is extremely verbose compared to any stored procedure syntax I've ever encountered.
I do not fail; I succeed at finding out what does not work.
http://www.brightball.com/postgresql/why-should-you-learn-postgresql
Its not MySQL users starting the pissing contest. Its *ALWAYS* some annoying guy saying "Teh Postgress iz da bomb and you are all rong for using MySQL". Every. Time. And they try and try, and I still don't care. I'm using Mariadb instead, and I'm completely happy. When I need assistance, I pay them. Its a good-enough deal for me. Thanks again for your time. Buh bye.
Nervals Lobster's last 15 posts have been links to news.dice.com, the parent company of Slashdot. They're nothing but ads.
[Add obligatory Slashdot's-going-to-hell-in-a-handbasket slam here.]
Left a test Oracle server running overnight accidentally a number of years ago it had been owned by time I got in the next day
Absolute rubbish! Tthe person you responded to provided the fact that MSSQL is the _ONLY_ (read that twice) DB product to ever have a known exploit all on it's own. Not that someone "forgot" to configure some security, but that it's ownable just by running regardless of how you secure the server. What you are describing is your fuckup, not Oracle's fuckup. Yeah, we all make mistakes but most of us don't try to badmouth innocent parties when describing ours.
Take a query that joins against 10 or more tables. Yes, it happens in the real world. I have seen at least 16, not counting subqueries. Run it in MySQL and it is slow. Don't do that, some may say. But this is what SQL is for, to relate tables. Breaking it apart because your database server sucks just means that you picked the wrong database. Run the same complex query in PostgreSQL or any commercial database, and it runs just fine. MySQL has an undeserved reputation for being fast. It is only fast when you do not make the same basic safety guarantees that PostgreSQL or any commercial databases offer by default.
Plus, MySQL has fugly syntax. If you know Oracle and Microsoft SQL Server, then one of those two syntax's that you already know will work with PostgreSQL. MySQL is a database made by web developers who do not understand SQL or data safety or correctness. Want to store February 31st? MySQL will take it. Any other database says: "WTF is this?". It is poor for developing and testing code because it accepts dumb things like that.
AFAIK, the most popular RDBMS by installed base is still SQLite which the authors released into the public domain many years ago. It won't keep up with oracle's performance on very large data sets but it's a hell of lot less complex to set up, and as you say most business/consumer applications simply don't need the performance (and price tag) of something like Oracle or MSSQL.
And did you exchange a walk on part in the war for a lead role in a cage? - Pink Floyd.
Microsoft SQL:
- select top 100 * from table instead of select * from table limit 100
- White space after values is ignored ('Bob' = 'Bob ')
- Command-line client sucks
Oracle
- A column of type date is actually timestamp. There is no column type that stores just a date.
- Command-line client sucks
- expensive
MySQL
- You can quote strings with single ticks, double quotes, or backticks
- The MyISAM engine
- Query cache based on the text of the select statement, rather than its meaning. So slightly rewording your query will skip the cache. Also updating a single row will clear the cache. This is inferior to how I understand PostgreSQL's shared buffer cache, which keeps frequently read rows in cache, only flushing out the ones that are updated, and deciding whether to use the cache after the query is parsed, and so not dependent on the query being literally written the same way.
It's no wonder so few web developers fully exploit the powers of the database, reimplementing many of its features in PHP, poorly. I once went to a local PHP meeting. The leader gave a talk, mainly about object-oriented programming, which I never got into. Anyway, he also recommended some kind of job queue application, like to email new users a welcome message. Don't use your database for that, he said, because keeping track of who you've emailed in the users table would upset MySQL's delicate query cache. At the end of the talk, I asked the group of 20 or 30 who had used PostgreSQL. Nobody.
Like others have said, most web developers probably should use SQLite. It's great not only as an embedded database but also the backend for most of the little web apps out there. Or if you're writing business applications for a large company, use PostgreSQL. The rest can go to the dumpster.
200 comments and nobody has asked whether it's webscale or not. This place is going to the dogs already.
Confucius say, "Find worm in apple - bad. Find half a worm - worse."
I use Drupal 7 on Postgres 9.3.4 and it works like a charm, never crashed in 1.5 year.
I did have to convince the hosting provider to upgrade Postgres to a higher version, because we were the only ones not on MySQL, but after pointing out that they declared on their own site to being technically advanced etc they did this.
I've used MySQL for almost 20 years for different projects of mine. In my professional life, I've also used ADABAS, Oracle and this and that other.
I was interested in Postgres some years ago but never went beyond reading one book. Then two years ago I decided to start a new project with Postgres from the start, because I wanted PostGIS.
I'm not looking back. Every future project I do will always use Postgres. Aside from the technical and functional and other rational arguments, the feeling you get is like graduating from BASIC to a real programming language.
Assorted stuff I do sometimes: Lemuria.org
So what? They both work well. Use the tool that works best for you. This is a dumb debate.
I've always favored postgresql for those reasons and it never really was that much slower than mysql but others always following the herd and drooling/slobbering mysql which I never felt was a battle that was worth the cost and lived with what was a halfassed db on many projects. Backing up mysql was always "fun" back in the day... especially when it would silently phailwhale, which was often...
One thing very relevant for discussion, that I didn't see mentioned here, is how connections are handled across the different RDBMS. PG still uses one process per connection. This can make its memory utilization grow substantially under high connection counts. Oracle and Mysql don't suffer from this issue.
The biggest problem I find with the Express edition is backups. You cannot use a regular file-based backup system to backup such databases due to locks, data pointers, etc. The paid edition has scheduled backup dumps built in.
There are tricks, such as scripts to deactivate the DB, copy the files, and re-activate it, but that's too risky and clunky.
Does anybody know a better way to get backups from E?
Table-ized A.I.
Yes, PowerShell scripts to trigger a copy-only backup - no issues with locking etc, no need to take the db off line or anything of that ilk.
Stored Procedures are big for me, and MySQL is my absolute favorite. It's also really simple to create MySQL UDFs (user defined functions). I wrote and currently maintain MVProc (on SourceForge), which uses every feature MySQL offers in stored procs. I have wanted since the beginning to implement MVProc for other databases, especially PostgreSQL, but it's so feature poor I can't make it work without creating an entirely different product. Just my 2 cents.
Retired from software... maybe. Sort of.
I've seen multiple sources that say NOT to backup while the database is on-line. Maybe one can get lucky and nothing bad happens regarding pointer references or locks most of the time after hours, but is that good enough? If you want to gamble that much, use MS-Access; it's nimbler to set up and change.
Table-ized A.I.
...so essentially, the author of this article sat back and tried to comprehend why anyone else would use a database that he would never use, put himself in their position, fap, and blog about it, only to conclude that he still loves the one he uses commonly, to begin with. I think the influx of reddit migrants has sent slashdot back to n00b flamebait central.
the only permanence in existence, is the impermanence of existence.
When ExtJS changed their license to GPL3, not LGPL, as you would expect for a library.
The owner of Sencha then put out a statement that if you built something that made use of ExtJS, then you had to release your software under GPL3 ... including the server components.
I have no problem with releasing the client side -- that's all javascript that people could view the source and see ... but releasing the server side? That requires security audits and a review by legal ... it's just not going to happen.
Reading the review, the reviewer seemed to have the same take on what GPL meant from the statement :
Now, if the issue is simply the *client* code, then you could get around it by using ODBC, or something like Perl's DBD::mysqlPP, which doesn't use the MySQL client code. Do you have to release the whole application if it's just something that makes use of a mysql database? I don't know, but with all other things being equal, and more and more people coming to this conclusion, I'd rather just stick with something that's LGPL or MIT.
Build it, and they will come^Hplain.
If you have a team of unemployed DBA plodders that you need to provide work for, and an employer that needs to get rid of piles of money fast as a tax dodge, use Oracle, ...
Where are we going and why are we in a handbasket?
Copy-only is fine for online databases, you will never have an issue with locks etc as its specifically designed to cope with them.
Also the action of copy-only is done by the database engine, so it knows what it has to deal with.
Incase you are misunderstanding, copy-only is an option you provide to SQL Server when copying the database via SQL commands and the database engine, it has nothing to do with dealing with the actual data files the live database is using.
I would never advocate backing up the actual mdf and ldf files, always use the systems the database engine provides because that knows better than you how to handle various situations and will flush stuff to disk as needed.
The author conveniently left this out. Anyone who actually works with large datasets, especially time series data knows how huge this is. Cassandra clusters scale linearly. I say mariadb and cassandra is a match made in heaven. You can mix and match acid and nosql as you please. Json document stores are for front end web devs and script kiddies. there are many features missing is postrges as well. many because the developers at postgres simply don't listen to their users . no Multi-source Replication, hints etc. etc.
test
From a developers standpoint either are good... Pros and cons for each.
BUT
Postgres does not do Master Master streaming replication, which means hitless upgrades, VIP fail over and fail backs at ease just are not possible.
Uhuh
The dangers of excessive individualism are nothing compared to the oppressiveness of excessive collectivism
A few months back, we had completed initial development on a new persistence layer on a demanding application. We'd put it all into PostgreSQL, and were enjoying the easy JSON and other features. It worked great.
So we got it up and running on high-end hardware in our five data centers, then we turned on the pipes for all the writes. But our systems team members were going insane, trying to get High Availability working right. It turns out that there is just no good way to accomplish this in PostgreSQL. It could fail over to the slave if the master stopped responding, but fail-back was basically impossible. It had to do an rsync on the file system level, which was expected to fail. When it failed, the docs said, just do it again. It took almost a full day to run, each time.
And it failed with alarming regularity! When under load, every couple of days the database would just freeze for ten to fifteen minutes, choking on some non-scary query. It would just sit there, stuck. Calls to it would just block, and eventually timeout. When this happened, it would fail over to the slave, and we're days away from getting back to a sane state.
Don't think we didn't do our best to solve this issue. We spent many thousands of dollars on two different highly recommended consulting companies, who specialized in PostgreSQL. They came onsite and looked at everything, and recommended a number of configuration adjustments, but nothing helped.
In desperation, the project now seriously behind schedule, we worked over Christmas, and branched the code to use MySQL as the database, instead of PostgreSQL. Then we set up two parallel systems. Both on identical high-end hardware ($50,000 machines), one for each database, and turned on all the pipes.
The result? MySQL answered its queries in 50% less time than PostgreSQL. Plus we already knew that it did HA quite well, and it never just froze up like PostgreSQL would.
We have since completely obliterated all traces of PostgreSQL from our code base.
--- wad
The Express edition does not have those features. It's why it's free.
Table-ized A.I.
That's funny, I use copy-only backups all the time on SQL Server Express.
Stop talking out of your arse.
Is your rudeness necessary? I helps nothing.
Well, it hasn't worked for us, and I've found others complaining about it on the Internet also. There are work-arounds, but they are hokey and assume certain permission access levels.
Note that I am talking about automatic periodic backups, not one-time manual runs.
Table-ized A.I.
Is your rudeness necessary? It solves nothing.
It hasn't worked for us, and others have reported similar on forums. There are round-about work-arounds, but they have a lot of layers and dependencies. Not worth risk to save a buck.
Note I am talking about automatic periodic backups, not one-time manual backups.
(My apologies if this message shows up twice. The first didn't appear for some reason after submitting. I can't rule out Mondayitus.)
Table-ized A.I.