161 points · by yannikyeo · 8y ago · 37 comments
JSONB is clearly a lot more complex and demanding, but if you're ever using PostgreSQL and hitting performance limitations with interpreted languages or PL/pgSQL, it's an option which is not as scary and inaccessible as you might imagine.
CREATE EXTENSION is what really made this stuff usable. Before this, you had to get the user to run a bunch of raw SQL to set all the types and functions, but now it's all wrapped in a single handy SQL statement which can even handle upgrades and uninstallation.
Part of me wants the installation and upgrade mechanism to be reusable for my own application database schemas, it's so convenient and well done.
Turns out a few people have been working on doing just that.
* JSONDC, a PostgreSQL extension written in Rust. Latest commit about a month ago. 161 commits in total. Authors say “It is written in Rust and, being short, is a good skeleton project for other would be plugin authors who'd like to use Rust to write Postgres extensions”. https://github.com/instructure/jsoncdc
* pgxr. Latest commit 20 days ago. 23 commits in total. “Write PostgreSQL extension functions (as stored procedures) using Rust.”. https://github.com/clia/pgxr
* RPGFFI. Latest commit about a year ago. 33 commits in total. “Imagine being able to create postgresql extensions in rust. We generate bindgen (0.29.1) pg apis for [...]”. https://github.com/posix4e/rpgffi/
* postgres-extension.rs. Latest commit over 2 years ago. 23 commits in total. “Library to write Postgres extensions in Rust! Overall, the Postgres codebase has some pretty narly C macros everywhere, so we have to work around them a little bit.” https://github.com/thehydroimpulse/postgres-extension.rs
Anyone knows how Postgres really handles data coming from Foreign data wrappers?
Will Postgres build an index for the columns? Does it leverage the Postgres query planning?
You _can_ run ANALYZE on foreign tables:
"When use_remote_estimate is true, postgres_fdw obtains row count and cost estimates from the remote server and then adds fdw_startup_cost and fdw_tuple_cost to the cost estimates. When use_remote_estimate is false, postgres_fdw performs local row count and cost estimation and then adds fdw_startup_cost and fdw_tuple_cost to the cost estimates. This local estimation is unlikely to be very accurate unless local copies of the remote table's statistics are available. Running ANALYZE on the foreign table is the way to update the local statistics; this will perform a scan of the remote table and then calculate and store statistics just as though the table were local. Keeping local statistics can be a useful way to reduce per-query planning overhead for a remote table — but if the remote table is frequently updated, the local statistics will soon be obsolete."
https://www.postgresql.org/docs/11/postgres-fdw.html#id-1.11...
Postgres seems so chock-full of features now - is there a reason to prefer MySQL? Easier replication?
https://hnprofile.com/compare?search=postgres,mysql
Reddit has PostgreSQL up by about 40% over MySQL:
Someone once said, and I agree, "PostgreSQL is the answer unless proven otherwise." If you've not tried PostgreSQL I encourage you to give it a whirl, I think you'll like it. I'll also say that #postgresql is really a friendly place for newbies and experts alike.
[1] https://www.hntrends.com/2018/oct-react-holds-off-python.htm...
[2] https://trends.google.com/trends/explore?date=2012-01-01%202...
Personally not seeing large scale move away from MySQL.
As an AWS and PostgreSQL user, I wish it were the other way around, but that is currently the unfortunate truth.
Perhaps, but I suspect people who are migrating from mysql are moving to mariadb, not postresql.
> Postgres seems so chock-full of features now
Now? PostgreSQL has always been more feature-rich ( especially compared to mysql ). What made mysql popular was it's lack of features ( simplicity ) and its tie-in with php/etc web development. Web developers loved mysql because it was simple and easier to manage because it was so feature poor. Give credit where it is due. MySQL really rode the web development momentum. But PostgreSQL has always been the more mature RDBMS.
This is a basic features list ( maybe somewhat biased and somewhat dated ) but the overall trend still holds today.
I see a fair number of local job postings that specify Postgres experience.