661 points · by jkatz05 · 2y ago · 148 comments
Massive improvements to vacuum operations:
"PostgreSQL 17 introduces a new internal memory structure for vacuum that consumes up to 20x less memory."
Much needed features for backups: "pg_basebackup, the backup utility included in PostgreSQL, now supports incremental backups and adds the pg_combinebackup utility to reconstruct a full backup"
I'm a huge fan of FDW's and think they are an untapped-gem in Postgres, so I love seeing these improvements: "The PostgreSQL foreign data wrapper (postgres_fdw), used to execute queries on remote PostgreSQL instances, can now push EXISTS and IN subqueries to the remote server for more efficient processing."I'm pretty sure I could read them when needed with fdw. Is it a good idea?
I think it can be slow but maybe I could use materialized views or something.
Duckdb can run SQL across the different data formats and insert or update directly into postgres. I run duckdb with python and Prefect for batch jobs, but you can use whatever language or scheduler you perfer.
I can't recommend this setup enough. The only weird things I've run into is a really complex join across multiple postgres tables and parquet files had a bug reading a postgres column type. I simplified the query (which was a good idea anyways) and it hums away
I'm hoping it's less wasteful than truncating and importing the whole table every time there is one single change.
- If the foreign server is close (latency) that’s great
- if your query is complex then it helps if the postgres planner can “push down” to mssql. That will usually happen if you aren’t doing joins to local data
I personally like to set up the foreign tables, then materialize the data into a local postgres table using pg_cron. It’s like a basic ETL pipeline completely built into postgres
Do you have any recommendations on how to manage credentials for `CREATE USER MAPPING ` within the context of cloud hosted dbs?
It is so nice having json functionality in a relational db - even if you never actually store json in your database, its useful in so many situations.
Being able to generate json in a query from your data is a big deal too.
Looking forward to really learning json_table
Disk space to store the returned data is cheap and can be periodically flushed only when you are certain the content has been properly extracted.
That’s a very good idea!
Bit sad the UUIDv7 PR didn't make the cut just yet:
Where is the iceberg complexity?
1. Chipping away more at vacuum. Fundamentally Postgres doesn't have undo log and therefore has to have vacuum. It's a trade-off of fast recovery vs well.. having to vacuum. The unfortunate part about vacuum is that it adds load to the system exactly when the system needs all the resources. I hope one day people stop knowing that vacuum exists, we are one step closer, but not there.
2. Performance gets better and not worse. Mark Callaghan blogs about MySQL and Postgres performance changes over time and MySQL keep regressing performance while Postgres keeps improving.
https://x.com/MarkCallaghanDB https://smalldatum.blogspot.com/
3. JSON. Postgres keep improving QOL for the interop with JS and TS.
4. Logical replication is becoming a super robust way of moving data in and out. This is very useful when you move data from one instance to another especially if version numbers don't match. Recently we have been using it to move at the speed of 1Gb/s
5. Optimizer. The better the optimizer the less you think about the optimizer. According to the research community SQL Server has the best optimizer. It's very encouraging that every release PG Optimizer gets better.
But even then, in some recent tests I did, Postgres was less than 0.1 msec slower. And if the schema and queries were not designed with InnoDB in mind, Postgres had little to no performance regression, whereas MySQL had a 100x slowdown.
I love MySQL for a variety of reasons, but it’s getting harder for me to continue to defend it.
I once met an older gentleman who was doing IT work for a defense contractor. He seemed nice enough. We were making small talk and I happened to mention that I had recently installed Linux on my computer at home. He tone changed almost immediately and he started ranting about how Linux was pirated source code, stolen from Microsoft, all of it contains viruses, etc. He was talking about the SCO vs Linux lawsuits but of course got absolutely ALL of the details wrong, like which companies were even involved in the lawsuits. He was so far off the deep end that I didn't even try to correct him, I just nodded and smiled and said I was actually running late to be somewhere else...
What’s the rationale? What do you gain?
Also, MSSQL have few things going for it, and surprisingly no one seem to be even trying to catch up
- Their BI Stacks (PowerBI, SSAS)
- Their Database Development (SDK) ( https://learn.microsoft.com/en-us/sql/tools/sql-database-projects/sql-database-projects?view=sql-server-ver16 )
The MSSQL BI stack is unmatched , SSAS is the top star of BI cubes and the second option is not even closeSSRS is ok, SSIS is passable , but still both are very decent
PowerBI and family is also the best option for Mid to large (not FAANG large, but just normal large) companies
And finally the GEM that is database projects, you can program your DB changes declaratively, there is nothing like this in the market and again, no one is even trying
The easiest platformt todo evolutionary DB development is MS SQL
I really wish someone will implement DB Projects (dacpac) for Postgresql
Is it a home run if the end users aren’t on Windows or using Excel? I’m thinking about the feature where you can use a SQLServer DB as a data source to Excel.
because the literal expansion 'business intelligence' (or the explanation in the Wikipedia article) is hard to interpret as something that makes sense in contexts like this where you're apparently talking about features of software rather than social practices. the reference to 'bi cubes' makes me think that maybe it means 'olap'?
Bytebase did https://www.bytebase.com/docs/change-database/synchronize-sc...
Automatic migration tools have essentially been doing this for a while (e.g. Django migrations). But I agree it would be nice if Postgres had better support built in.
But this is also a gateway drug for cloud addiction.
Besides, managing Microsoft licensing is a bliss close to Oracle's. And yeah, MSSQL is much better in almost every way than Oracle.
If you only compare those two, it's a non-brainier.
- Do you use any cloud provider? Those platforms are built on top of open source software: Linux, nginx (e.g Cloudflare's edge servers before the rust rewrite), ha-proxy (AWS ELB), etc - Either the software your business builds or depends on probably uses open source libraries (e.g: libc, etc) - The programming languages your business uses directly or indirectly are probably open source
My point is that folks that make these kinds of statements have no clue how their software is built or what kind software their business actually depends on.
The part that your boss doesn't trust Postgres is hilarious, of course.
The more deeply your business depends on something, the more careful you need to be when selecting the source for that something. (And the db is often very deeply depended on.)
You want to see why their long-term incentives align with your own needs.
But a revenue stream is just one way to do this, and not a perfect one. (Case in point: Oracle.)
In my experience, SQL Server isn't bad though. I know a couple commercial products that started with SQL Server in the late '90s and remain happy with it now. The cost hasn't been a problem and they like the support and evolution of the product. They find they can adopt newer versions and features when they need to without too much pain/cost/time.
(Not that I don't think Postgres is generally a better green-field pick, though, and even more so porting away from Oracle.)
> PostgreSQL 17 supports using identity columns and exclusion constraints on partitioned tables.
> PostgreSQL 17 also includes a built-in, platform independent, immutable collation provider that's guaranteed to be immutable and provides similar sorting semantics to the C collation except with UTF-8 encoding rather than SQL_ASCII. Using this new collation provider guarantees that your text-based queries will return the same sorted results regardless of where you run PostgreSQL.
- [1] https://github.com/LemmyNet/lemmy-ansible/blob/main/UPGRADIN...
https://github.com/docker-library/postgres/issues/37#issueco...
Btw, what do you find convoluted about our project (pgautoupgrade)?
It started out as super simple like you mention above... but it also started out using Alpine images so didn't work so well for people coming from Debian based ones. We've added support for Debian based ones now too, but that's introduced more complexity to the README (as has other options). o_O
What's more, even outside of docker running `pg_upgrade` requires both version to be present (or having older binary handy). Honestly, having the previous version logic to load and process the database seems like it would be little hassle but would improve upgrading significantly...
It's not perfect, as it doesn't (yet) recreate indexes or automatically run `vacuum analyze` afterwards. We're working on those though. :)
You do make backups of your database though yeah?
I hope to one day see Incremental View Maintenance extension (IVM) be turned into a first class feature, it's the only thing I need regularly which isn't immediately there!
Or you could use triggers to build one: https://hypirion.com/musings/implementing-system-versioned-t...
https://illuminatedcomputing.com/posts/2024/07/temporal-reve...
SELECT random(1, 10) AS random_number;
https://neon.tech/blog/postgres-17
(note that not all extensions are available yet, that takes some time still)
every year a new postgres release occurs and i want to try out some of the features i have to find a way to get it. usually nobody has it available.
here's the list of homebrew options I see right now:
brew formulae | grep postgresql@ postgresql@10 postgresql@11 postgresql@12 postgresql@13 postgresql@14 postgresql@15 postgresql@16
maybe you're seeing otherwise but i updated a min ago and 17 isn't there yet. even searching for 'postgres' on homebrew doesn't reveal any options for 17. i don't know where you've found those but it doesn't seem easily available.
and i'm not suggesting you use a cloud service as an alternative to homebrew or local development. neon is pure postgres, the local service is the same as whats in the cloud. but right now there isn't an easy local version and i wanted everyone else to be able to try it quickly.
Its not quite visible yet, but all this progres by postgres (excuse the pun) on making JSON more deeply integrated with relational principles will surely at some point enable a new paradigm, at least for full stack web frameworks?
I don't think you'll see a paradigm shift. You'll just see people using other documents stores less.
I’d say they’re then surprised when their DB calls are slow (nothing to do with referential integrity, just the TOAST/DETOAST overhead), but since they also haven’t experienced how fast a DB with local disks and good data locality can be, they have no idea.
I hope SQLite3 can implement SQL/JSON soon too. I have a library of compatability functions to generate the appropriate JSON operations depending on if it's SQLite3 or PostgreSQL. And it'd be nice to reduce the number of incompatibilities over time.
But, there's a ton of stuff in the release notes that jumped out at me too:
"COPY .. ON_ERROR" ignore is going to be nice for loading data anywhere that you don't care if you get all of it. Like a dev environment or for just exploring something. [1]
Improvements to CTE plans are always welcome. [2]
"transaction_timeout" is an amazing addition to the existing "statement_timeout" as someone who has to keep an eye on less experienced people running SQL for analytics / intelligence. [3]
There's a function to get the timestamp out of a UUID easily now, too: uuid_extract_timestamp(). This previously required a user defined function. So it's another streamlining thing that's nice. [4]
I'll use the new "--exclude-extension" option for pg_dump, too. I just got bitten by that when moving a database. [5]
"Allow unaccent character translation rules to contain whitespace and quotes". Wow. I needed this! [6]
[1] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
[2] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
[3] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
[4] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
[5] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
[6] https://www.postgresql.org/docs/17/release-17.html#RELEASE-1...
Is this available anywhere? Super interested
The most useful part is doing set intersection operations on JSON array's. Probably the second is extracting a value by path across both.
It's not crazy to implement, SQLite was the harder side. Just a bit of fiddling with `json_each`, EXISTS, and aggregate functions.
https://www.postgresql.org/docs/17/functions-json.html#FUNCT...
https://repost.aws/questions/QUbIn2WmXgTbiVu_4wua9tUw/dms-wi...
I wonder how open postgres is and what kind of pull requests postgres team considers? I'd like to learn how to contribute to PG in baby steps and eventually get to a place where I could contribute substantial features.
I'd guess that this may fit your purpose to add a custom format without having to fork upstream.
Basically in a database with a lot of creation/deletion, database activity can outrun the vacuum, leading to out of storage errors, lock contention, etc
In order to keep throughput up, we had to throttle things manually on the input side, to allow vacuum to complete. Otherwise throughput would eventually drop to zero.
I’m not discounting your experience as anything is possible, but I’ve never had to throttle writes, even on large clusters with hundreds of thousands of QPS.
Thank you contributors!