PostgreSQL 16 Beta 1
postgresql.org
postgresql.org
Personal favorites on the list include:
- load_balance_hosts, which is an improvement to libpq so you can load balance across multiple Postgres instances.
- Logical replication on standbys
- pg_stat_io which is a new view that shows IO details.
Is this a replacement for PG bouncer and similar?
(EDIT: if you don't know this already - the _establishment_ of connections is also super expensive. so another reason to pgbounce is to keep connections persistent if you have app servers that are constantly opening and closing conns, or burst open conns, or such like. Even if the total conns to pg doesnt go super high, the cost of constantly churning them can really hurt your db)
Essentially, a "please serialize everything (temp tables, SET GUC values, etc) from this session to disk and load it back when necessary".
interestingly enough this is what Oracle does AFAIK. They are also process-per-conn & have an optional sidecar proxy thingy that you can run on your oracle host to do the pooling. I would rather it be built more tightly into the rdbms but thats not a terrible solution.
Historically connection state and "process state" have been tightly coupled, for good server-side pooling they have to be divorced. While good pooling is doable with the current process model (passing the client file descriptor between processes using SCM_RIGHTS), it's much harder with processes than with threads - this is one of the reasons I think we will eventually need to migrate to threads.
Eventually I want to get to a point where we have a limited number of "query execution workers" that handle query execution, utilized by a much larger number of client connections (which do not have dedicated threads each). Obviously it's a long way to go to that. Ah, the fun working on an complicated application with a ~35 year history.
There also are use cases for pgbouncer that cannot be addressed on the server-side - one important one is to run pgbouncer on "application servers", to reduce the TCP+TLS connection establishment overhead and to share connections between application processes / threads. That can yield very substantial performance gains - completely independent of server side pooling support.
Crunchydata mentioned it on their blog a while back (https://www.crunchydata.com/blog/five-tips-for-a-healthier-p...) and the pg 14 release notes mention a few changes to idle sessions (https://www.postgresql.org/docs/release/14.0/)
I don't know if they were sufficient that pgbouncer is no longer necessary, haven't had a need to try it.
It's fundamentally a question of how the connection listener communicates with the rest of the database, e.g., using shared memory or some other IPC mechanism, work queues, etc. Having too many connections results in problems with concurrent access and lock contention independent of how heavyweight the actual listening process is.
Not the same service(s) as PG even if it's the same protocol, so I know it's really beneficial for connection queueing WRT my scenario for PG, but no idea on the CDB side.
https://techcommunity.microsoft.com/t5/azure-database-for-po...
Still waiting for automatic incremental updates for materialized views - been worked on for several years but still not released!
https://wiki.postgresql.org/wiki/Incremental_View_Maintenanc...
https://planetscale.com/blog/how-planetscale-boost-serves-yo...
- the materialized view is a plain table, so
- you can write to it from triggers
- you can have triggers on it
- refreshing a view records the deltas in a
history table (which is useful as a poor
person's logical replication scheme)
- you can mark a view as needing a refresh
Then in the application I have hand-coded triggers to either update the view's materialization directly or to mark the view as needing a refresh. A background job can asynchronously refresh views as needed.I've also spent some time thinking about the AST form of view queries that PG stores and how one might automatically generate triggers on source tables that update the materialization or mark it as needing a refresh.
As you note, many queries can be very difficult to transform into queries that compute incremental deltas. Moreover, even where it's possible to do that, the time it takes to execute the delta computation might be unacceptably long. For example, if you have a recursively nested grouping schema and you want to maintain a view of the expanded transitive closure of that data, then removing a large from from another might require thousands of row deletions from the materialized view, and that might make the transaction take much too long in a UI -- the obvious thing to do here is to say "sorry, that kind of update takes a while to propagate, but your transaction will complete quickly", so just mark the view as needing a refresh and refresh it asynchronously.
[0] https://github.com/twosigma/postgresql-contrib/blob/master/m...
On the other, it's pretty confidence-inspiring that they don't put stuff in until they're sure it's ready.
- pg_hba.conf and pg_ident.conf can include other files
- Logical replication apply can use non-PK btree indexes
- Integer literals in non-decimal bases
- Underscores in numeric literals
- Subqueries in the FROM clause can omit aliases
- Addition and subtraction of timestamptz values
- pg_upgrade can override new cluster's locale and encoding
https://commitfest.postgresql.org/19/1741/ (index skip scan/loose index scans) would be very welcomed... I think. Not sure how many people run into it in the wild.
It says "target version: 16" but "returned with feedback" and hasn't been bumped in 14 months. :( First opened in 2018.
This is great. It never made any sense to me that this was required. For people who are unaware, say you want to understand a table a natural way of doing it might be
select *
from the_table
order by some_metric desc
limit 10
so you'd think you can do the same for queries like select *
from (
select blah blah blah the rest of the query
) a
order by some_metric desc
limit 10
you need to put the alias 'a' to placate existing postgres even though it's never actually used, which never made any sense to me.And FYI this comes from ANSI SQL.
array_agg is particularly interesting, because it lets you implement patterns like this: https://til.simonwillison.net/sqlite/related-rows-single-que...
Load Balancing from client libs
Support for CPU acceleration using SIMD for both x86 and ARM architectures, including optimizations for processing ASCII and JSON strings
new pg_stat_io view that provides information on I/O statistics
Nice to see the continued advancement and progression all around.
As to where, AWS offers Windows as do many other cloud providers, including a significant portion of Azure VMs. Not to mention, that MS-SQL and SQL-Edge both run on Linux. IIRC, Azure Cloud SQL is also MS-SQL running a non-windows version. There's also Linux/x86_64 Docker images.
Aside: if you're willing to write a big check, MS-SQL replication configuration is far easier than pretty much anything else to setup and configure (UI based flows or scripted). While I personally advocate for PostgreSQL, I've used and mostly like MS-SQL fine.
But yeah, obviously they're behind in that area!
Given the current release pace, I'd love to have another upgrade path than `pg_dump | psql`. That would remove a great deal of friction in prod.
pg_upgrade
At least with Ubuntu and RedHat/CentOS/Rocky/... installing two versions in parallel is absolutely no problem.
I think Ubuntu even wraps that into their upgrade scripts and you can pass an option to use pg_upgrade or pg_dump/pg_restore
I'm happy to let you know that PostgreSQL 16 Beta 1 is available in the Amazon RDS Database Preview Environment (https://aws.amazon.com/about-aws/whats-new/2023/05/postgresq...). I hope you get a chance to test, I'm very eager to here any and all feedback about PostgreSQL 16.
Would you also know by any chance when RDS will get Graviton3 instances in non-Dublin EU regions?
FWIW, there have been smaller prerequisites merged into 15 already, and 16 has a number of improvements that are part of that work. E.g. the more scalable relation extension (making COPY scale much better), and the related buffer mapping changes, come from the AIO effort.
Personally I think the feature is using asynchronous IO and direct IO support is part of that :)