Great to see MySQL adding this stuff! There's still a ton of reasons to choose Postgres and more and more silicon valley startups seem to be choosing pg - I don't remember the last time I met a startup choosing MySQL.<p>DBMSs are giant complex pieces of software with a million features - it's really hard to compare them. But if I had to sum it up, you can dump freaking line noise into Postgres and then hide the nastiness and manage and query it like a well-designed database. If you have a pretty database, good for you, but today's app writers have gotten lazy with NoSQL record stores and their databases resemble vomitoriums - and let's not talk about what people used to do in the 80s and early 90s.<p>Without further ado, Postgres vomitorium cleanup features:<p>- user defined functions/aggegrates/windowfuncs <i></i>in your favorite language<i></i> incl JavaScript, which means you can write tricky business logic once and run it where the data is, vs pulling out millions of records from the database. Language list: <a href="https://www.postgresql.org/docs/10/static/external-pl.html" rel="nofollow">https://www.postgresql.org/docs/10/static/external-pl.html</a><p>- foreign data wrappers with hundreds of connectors AND a 5 minute toolkit for authoring new wrappers in python and other scripting languages.
<a href="https://wiki.postgresql.org/wiki/Foreign_data_wrappers" rel="nofollow">https://wiki.postgresql.org/wiki/Foreign_data_wrappers</a>
<a href="http://multicorn.org/" rel="nofollow">http://multicorn.org/</a><p>- index goddamned anything. Postgres has the most array of index types of any open source database AND if you need, you can easily write a function (in javascript or python!!!) and create an index that's the result of that function call. Postgres even has a full range of partial indices and block range indices, which make it practical to index massive and sparse datasets. <a href="https://www.postgresql.org/docs/current/static/indexes-partial.html" rel="nofollow">https://www.postgresql.org/docs/current/static/indexes-parti...</a>
<a href="https://www.postgresql.org/docs/current/static/indexes-expressional.html" rel="nofollow">https://www.postgresql.org/docs/current/static/indexes-expre...</a>
<a href="https://www.postgresql.org/docs/current/static/brin-intro.html" rel="nofollow">https://www.postgresql.org/docs/current/static/brin-intro.ht...</a><p>EXAMPLE: I was once handed a MySQL database of IoT signals where timestamps were in seconds since the epoch and asked to report on this data without changing the database. No biggie: 15 minutes to replicate this OLTP database to a read-only Postgres replica (dumb schema mapping) - then a Postgres VIEW to hide this nastiness and a function index on the timestamp column (to_timestamp).<p>(from memory)
CREATE VIEW foo AS SELECT *, to_timestamp(mysql_ts_col) as ts_timestamp FROM replicated_mysql_table;
CREATE INDEX foo_ts_inx ON replicated_mysql_table(to_timestamp(mysql_ts_col));<p>At another company, we got dumped a load of JSON and weren't sure how we'd need to parse it. No biggie, I just created indices using function calls that parsed the JSON.<p>- tons of native datatypes and extensible datatypes. In cases where you're handed complex structures or "weird" data that doesn't behave like most programmers expect, you can define new datatypes, then create a library of user defined functions around them. <a href="https://www.postgresql.org/docs/9.5/static/xtypes.html" rel="nofollow">https://www.postgresql.org/docs/9.5/static/xtypes.html</a><p>- sampling. Postgres has native, low-level support for queries that sample the data, which makes it super fast to explore data while preserving some semblance of statistics. <a href="https://blog.2ndquadrant.com/tablesample-in-postgresql-9-5-2/" rel="nofollow">https://blog.2ndquadrant.com/tablesample-in-postgresql-9-5-2...</a><p>- EXPLAIN. The Postgres planner/optimizer is still the king at explaining why your query is taking forever and what you can do about it. Admittedly, this stuff quickly gets arcane, but you can post your EXPLAIN output to a forum and guys like me will tell you how to override the JOIN order, update statistics, etc. <a href="https://www.postgresql.org/docs/current/static/using-explain.html" rel="nofollow">https://www.postgresql.org/docs/current/static/using-explain...</a><p>Finally, no conversation about Postgres vs <x> is complete without mentioning that ALMOST EVERY FEATURE IN POSTGRES WORKS WITH EVERY OTHER FEATURE, which means you don't waste hours investing in something and then "oops" your carefully written user defined function can't be invoked in some obscure place - with Postgres, you can assume everything just works and will keep working. There's few pieces of software that can claim this.