News for hackers. Stuff that matters.
Re:PostgreSQL 10 Released by coldcode on Thursday October 05, 2017 @10:59AM (#15409679)
I haven't worked with databases in a while, at my employer we are moving to MariaDB (from MySQL) - is there some reason why we wouldn't be considering PostgreSQL? Is there some drawback to P?
Re:PostgreSQL 10 Released by ComputerGuru on Thursday October 05, 2017 @11:20AM (#15409875)
While the other comments talk about the benefits of switching to pgsql (and I concur whole heartedly) it seems no one has addressed your specific case. Your company isn’t really “switching” to anything, MariaDB was a fork of MySQL when the license kerfuffle was going on and there were issues with the stewardship of the project. It’s more of upgrading to a newer release of MySQL than switching to a different database engine.

i.e. “switching” to MariaDB is probably just a sysadmin upgrading the software and no changes to your code or database queries (unless replication is involved) but pgsql will certainly require more involved changes to the software.

Re:PostgreSQL 10 Released by ngrilly on Thursday October 05, 2017 @11:12AM (#15409802)
PostgreSQL is really better at executing arbitrarily complex queries, and the documentation is so much better.

PostgreSQL also provides additional features like LISTEN/NOTIFY, Row Level Security, transactional DDL, table functions (like generate_series), numbered query parameters ($1 instead of ?), and many others.

In my opinion, the only reasons for choosing MySQL/MariaDB are if you absolutely need clustered indexes (also known as index organized tables — PostgreSQL uses heap organized tables) or if you architecture relies on specific MySQL replication features (for example using Vitess to shard your database).

Re:PostgreSQL 10 Released by SomeHacker44 on Thursday October 05, 2017 @01:10PM (#15410750)
Transactional DDL, by the way, is one of those things that once you use it, you can't imagine how you lived without it.
Re:PostgreSQL 10 Released by jeffdavis on Thursday October 05, 2017 @11:07AM (#15409747)
Technology choices are complex, so there are always some plausible reasons.

But at this point, I think PostgreSQL should be the default choice for most people for new systems, and then move away if you have some real problem with it. The chance of regret is a lot lower with postgres.

Re:PostgreSQL 10 Released by ngrilly on Thursday October 05, 2017 @11:13AM (#15409813)
I concur. I was hit (again) today by a choice of MySQL made a few years ago: https://medium.com/@ngrilly/dont-waste-your-time-with-mysql-....
Re:PostgreSQL 10 Released by snuxoll on Thursday October 05, 2017 @11:20AM (#15409881)
There's a drawback with any choice of technology, but PostgreSQL's are pretty well known.

Replication can be a bit of a pain to set up compared to anything in the MySQL family since the tooling to manage it isn't part of the core project (there are tools out there, like repmgr from 2ndQuadrant).

Similar story with backups, bring your own tooling - again, 2ndQuadrant has a great solution with barman, there's also WAL-E if you want to backup to S3 along with many others.

Uber certainly presented a valid pain-point with the way indexes are handled compared to the MySQL family, any updates to an indexed field require an update to all indexes on the table (compared to MySQL which uses clustered indexes, as a result only specific indexes need to be updated). If you have a lot of indexes on your tables and update indexed values frequently you're going to see an increase in disk I/O.

Someone else can probably come up with a more exhaustive list, but the first two are things I've personally been frustrated with - even with the tooling provided by 2ndQuadrant I still have to admit other solutions (namely Microsoft SQL Server) have better stories around replication and backup management, though the edge is in user-friendly tooling and not so much underlying technology.

On the other hand, PostgreSQL has a lot of great quality of life features for database developers. pl/pgsql is really great to work with when you need to do heavy lifting in the database; composite types, arrays and domains are extremely useful for complex models and general manipulation; full-fat JSON support can be extremely useful for a variety of reasons, as can the XML features; PostGIS is king when it comes to spatial data; and a whole hell of a lot more.

PostgreSQL is hands-down my favorite database because it focuses on making my life, when wearing the database developer hat, a lot nicer. With the DBA hat on it complicates things some compared to other products, but the tooling out there is at least decent so it's not a huge deal.

Re:PostgreSQL 10 Released by jimktrains2 on Thursday October 05, 2017 @11:49AM (#15410112)
Regarding replication, the logical replication in pg10 should make this significantly easier. Between that and "Quorum Commit for Synchronous Replication" I'm really excited to see how these pan out in production. Pg doesn't normally hype or talk about (or let into production) things that don't work.
Re:PostgreSQL 10 Released by snuxoll on Thursday October 05, 2017 @12:30PM (#15410467)
Logical replication really isn't going to fix the pain points I have with replication from a DevOps/Sysadmin perspective.

The biggest issue with replication in PostgreSQL is restoring a failed master, pg_rewind provides the low-level plumbing to do this and it's somewhat integrated into repmgr now - but it's far from being easy to use compared to something like SQL Server Availability Groups. Being the sole Linux sysadmin / PostgreSQL DBA in my organization means I have to take responsibility for this since the tools are complex enough I can't easily throw them over to our Windows admins or SQL Server DBA's in an emergency. This is partially an issue with staffing, but if the tooling was a little easier to understand and robust enough in fully-automatic operation I could just leave common troubleshooting steps in a runbook, but right now when replication breaks it REALLY breaks.

Re:PostgreSQL 10 Released by normaljoe on Thursday October 05, 2017 @11:07PM (#15414155)
That's because they are Windows admins and not nix admins. They probably don't have a good understanding of the command line and if they do not the rich nix command line.

I have a single pg admin in current project and he can throw most tasks to the Oracle (running on Linux) admins or even junior Linux admins.

While "complex" they are still fairly basic to command line admins.

Anything with less than 3 pipes or one regex should be simple to command line *nix person. Granted to excludes you including a complex AWK script or inline perl execution on the command line instead of in a file like a normal sane person.

Re:PostgreSQL 10 Released by X86BSD on Thursday October 05, 2017 @01:25PM (#15410865)
You know what's even easier? Zfs snapshots and zfs send/recv.
Re:PostgreSQL 10 Released by snuxoll on Thursday October 05, 2017 @01:27PM (#15410877)
ZFS snapshots don't handle the same use-case as streaming replication, I've got backups handled quite nicely with barman.
Re:PostgreSQL 10 Released by manigandham on Thursday October 05, 2017 @06:36PM (#15413081)
The major issue with logical replication is the lack of DDL replication, meaning any changes to your table structure will cause issues until the replicas are updated to match. Also an all tables subscription will not automatically pickup new tables, it needs to be refreshed too. At this stage, I'd recommend against using logical replication unless absolutely necessary because it doesn't really do what people would normally expect it to.
Re:PostgreSQL 10 Released by phil21 on Thursday October 05, 2017 @12:05PM (#15410251)
I typically say developers love PostgreSQL and sysadmins utterly despise it. The reverse holds true for MySQL.

> Replication can be a bit of a pain to set up compared to anything in the MySQL

This is a very large understatement.

Re:PostgreSQL 10 Released by fusiongyro on Thursday October 05, 2017 @11:10AM (#15409777)
Migrating to Postgres will certainly be significantly more work than going to MariaDB for you. But I would still recommend you consider it, because Postgres is safer, more powerful and has fewer edge-case behaviors. If your systems are highly-wedded to MySQL's idiosyncrasies, the difference in cost may be too high for you to do it right now, but I would seriously consider it.
Re:PostgreSQL 10 Released by mathnode on Thursday October 05, 2017 @11:22AM (#15409899)
MariaDB is a great choice over mysql, any day.

MariaDB compared to postgres is a difficult choice, both have a multitude of features. MariaDB 10 was a game changer for the mysql landscape.

To make postgres 10 as easy to scale as mariadb 10, and for query semantics in mariadb 10 to allow for the complexity that postgres 10 allows; both require tradeoffs in management tooling, development practices and understanding.

Neither of them are a silver bullet. They both require effort, like any RDBMS. But both are great choices.

Re:PostgreSQL 10 Released by shlomi-noach on Thursday October 05, 2017 @12:10PM (#15410293)
> MariaDB 10 was a game changer for the mysql landscape

Can you please elaborate in what respect?

Re:PostgreSQL 10 Released by mathnode on Friday October 06, 2017 @02:53PM (#15419353)
It's not Oracle for starters Shlomi. You should know that ...
Re:PostgreSQL 10 Released by YorickPeterse on Thursday October 05, 2017 @11:13AM (#15409808)
Not so much a reason to not use it, but something to keep in mind: queries such as `SELECT COUNT(*)` tend to be a bit more expensive in PostgreSQL compared to MySQL/MariaDB. This doesn't necessarily mean they're always slower, but it's something you should take into account.

Another thing to take into account is that updating between minor versions (major versions per 10.x) is a bit tricky since IIRC the WAL format can change. This means that upgrading from e.g. 10.x to 11.0 requires you to either take your cluster offline, or use something like pg_logical. This is really my only complaint, but again it's not really a reason to _not_ use PostgreSQL.

Re:PostgreSQL 10 Released by wolf550e on Thursday October 05, 2017 @11:18AM (#15409865)
`select count(star)` is fast only on non-transactional MyISAM storage engine which locks the whole table for a single writer and has no ACID support. It's not what people usually mean when they say they want an RDBMS.

When ACID support is required, you use InnoDB, and that has the same `select count(star)` performance as other database engines.

What workload do you have that you need exact count of rows in a big table? Because if the table is not big or if inexact count would suffice, there are solutions (e.g. HyperLogLog).

Re:PostgreSQL 10 Released by aaronbwebber on Thursday October 05, 2017 @11:28AM (#15409949)
Since 9.2 Postgres has had index-only scans which can substantially improve the performance of `SELECT COUNT(* )` queries. If you need to get exact counts, and your query plan is not showing an index-only scan, you should try adding an index on the columns you are filtering on to see if you can get the query to run on an index-only scan.*

* <all the usual caveats about attempting to tune query performance>

Re:PostgreSQL 10 Released by ngrilly on Thursday October 05, 2017 @11:16AM (#15409840)
> queries such as `SELECT COUNT(*)` tend to be a bit more expensive in PostgreSQL compared to MySQL/MariaDB

As far as I know, that's true when you use the MyISAM storage engine (which is non transactional), but not when you use InnoDB (which has been the default for years now).

Re:PostgreSQL 10 Released by ZitchDog on Thursday October 05, 2017 @11:14AM (#15409824)
With logical replication in PG 10 the wal issue shouldn't be a factor going forward :)
Re:PostgreSQL 10 Released by snuxoll on Thursday October 05, 2017 @11:22AM (#15409902)
Here's hoping someone writes an alternative to pg_upgrade to handle this automatically. Hell, I'd be willing to throw some money in.