TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PostgreSQL 15

655 pointsby jkatz05over 2 years ago

17 comments

CodeIsTheEndover 2 years ago
This release includes a feature I added [1] to support partial foreign key updates in referential integrity triggers!<p>This is useful for schemas that use a denormalized tenant id across multiple tables, as might be common in a multi-tenant application:<p><pre><code> CREATE TABLE tenants (id serial PRIMARY KEY); CREATE TABLE users ( tenant_id int REFERENCES tenants ON DELETE CASCADE, id serial, PRIMARY KEY (tenant_id, id), ); CREATE TABLE posts ( tenant_id int REFERENCES tenants ON DELETE CASCADE, id serial, author_id int, PRIMARY KEY (tenant_id, id), FOREIGN KEY (tenant_id, author_id) REFERENCES users ON DELETE SET NULL ); </code></pre> This schema has a problem. When you delete a user, it will try to set both the tenant_id and author_id columns on the posts table to NULL:<p><pre><code> INSERT INTO tenants VALUES (1); INSERT INTO users VALUES (1, 101); INSERT INTO posts VALUES (1, 201, 101); DELETE FROM users WHERE id = 101; ERROR: null value in column &quot;tenant_id&quot; violates not-null constraint DETAIL: Failing row contains (null, 201, null). </code></pre> When we delete a user, we really only want to clear the author_id column in the posts table, and we want to leave the tenant_id column untouched. The feature I added is a small syntax extension to support doing exactly this. You can provide an explicit column list to the ON DELETE SET NULL &#x2F; ON DELETE SET DEFAULT actions:<p><pre><code> CREATE TABLE posts ( tenant_id int REFERENCES tenants ON DELETE CASCADE, id serial, author_id int, PRIMARY KEY (tenant_id, id), FOREIGN KEY (tenant_id, author_id) -- Clear only author_id, not tenant_id REFERENCES users ON DELETE SET NULL (author_id) -- ^^^^^^^^^^^ ); </code></pre> I initially encountered this problem while converting a database to use composite primary keys in preparation for migrating to Citus [2], and it required adding custom triggers for every single foreign key we created. Now it can be handled entirely by Postgres!<p>[1]: <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;message-id&#x2F;flat&#x2F;CACqFVBZQyMYJV%3DnjbSMxf%2BrbDHpx%3DW%3DB7AEaMKn8dWn9OZJY7w%40mail.gmail.com" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;message-id&#x2F;flat&#x2F;CACqFVBZQyMYJV%3D...</a><p>[2]: <a href="https:&#x2F;&#x2F;www.citusdata.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.citusdata.com&#x2F;</a>
评论 #33206020 未加载
评论 #33197345 未加载
评论 #33198460 未加载
评论 #33197577 未加载
mullsorkover 2 years ago
SQL MERGE looks great! I hope I remember it when the time comes, instead of writing 3 separate queries.<p>edit: Postgres docs on MERGE: <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;15&#x2F;sql-merge.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;15&#x2F;sql-merge.html</a>
评论 #33190937 未加载
评论 #33190832 未加载
评论 #33197204 未加载
hellcowover 2 years ago
&gt; PostgreSQL 15 lets users create views that query data using the permissions of the caller, not the view creator. This option, called security_invoker, adds an additional layer of protection to ensure that view callers have the correct permissions for working with the underlying data.<p>Thank you, kind friends. This is a huge QOL improvement when using row-level security with views and is the top reason I&#x27;ll be upgrading from Postgres 13 to 15.
评论 #33193087 未加载
评论 #33194090 未加载
评论 #33192430 未加载
评论 #33197484 未加载
评论 #33196454 未加载
morleyover 2 years ago
I hate to ask a stupid question, but I&#x27;m new to administering a Postgres database.<p>Do admins <i>usually</i> upgrade their DBs with each major release? I&#x27;m guessing it&#x27;s highly contextual and depends on how easy it is to do so, but I&#x27;ve heard about places that never upgrade until it&#x27;s a huge problem for them to do so (in order to avoid an even worse problem.)
评论 #33193067 未加载
评论 #33191869 未加载
评论 #33192154 未加载
评论 #33202772 未加载
评论 #33192133 未加载
评论 #33192560 未加载
评论 #33191952 未加载
评论 #33192223 未加载
评论 #33193584 未加载
评论 #33192247 未加载
评论 #33192921 未加载
评论 #33194451 未加载
评论 #33204277 未加载
评论 #33192173 未加载
评论 #33191925 未加载
评论 #33192533 未加载
评论 #33191945 未加载
评论 #33191901 未加载
praveenwebover 2 years ago
MERGE feature is interesting. But specifically on the revoking CREATE permissions for the public (or default) schema, this is a step in the right direction. Some of the defaults in Postgres can be more secure. For example, the first time I use a POSTGRES_PASSWORD to configure a password, changing this password involves more steps than just changing the values of the ENV, because it doesn&#x27;t take the changed value there after.<p>Structured logging with JSON is going to improve a lot of debugging, again a great productive change.<p>Also, any idea when the docker image for Postgres 15 will be available?
评论 #33191732 未加载
jablover 2 years ago
What&#x27;s the status of zheap?<p><a href="https:&#x2F;&#x2F;wiki.postgresql.org&#x2F;wiki&#x2F;Zheap" rel="nofollow">https:&#x2F;&#x2F;wiki.postgresql.org&#x2F;wiki&#x2F;Zheap</a> seems to claim it has been rebased on top of 14.1, but generally progress seems slow?<p>Also <a href="https:&#x2F;&#x2F;cybertec-postgresql.github.io&#x2F;zheap&#x2F;" rel="nofollow">https:&#x2F;&#x2F;cybertec-postgresql.github.io&#x2F;zheap&#x2F;</a>
mastaxover 2 years ago
PostGIS 3.3.0 mentioned another improvement in this release: &quot;This version of PostGIS can utilize the faster GiST building support API introduced in PostgreSQL 15.&quot;<p><a href="https:&#x2F;&#x2F;postgis.net&#x2F;2022&#x2F;08&#x2F;27&#x2F;postgis-3.3.0-released&#x2F;" rel="nofollow">https:&#x2F;&#x2F;postgis.net&#x2F;2022&#x2F;08&#x2F;27&#x2F;postgis-3.3.0-released&#x2F;</a>
评论 #33191709 未加载
systemvoltageover 2 years ago
Just some feedback for releases of any software: I think apt sources and repositories should be ready to go on launch and PR-release so people can immediately use the new version. Looks like that&#x27;s going to take 2-3 days. Sources are available but that&#x27;s not something most people want to delve in with make files and dependencies. Something like postgres is huge. Right now, if you go to downloads and expect postgresql-15 available, it is not; lot of people on IRC and elsewhere on Twitter are confused where to download postgresql-15. I know that takes time, so the PR release should just be delayed until apt sources are ready. May be also docker repositories.
评论 #33196179 未加载
评论 #33196309 未加载
throw0101aover 2 years ago
Is there anything like Galera for PostreSQL? I find it very convenient for small-scale HA and redundancy and it&#x27;s quite easy to get going.
评论 #33192339 未加载
评论 #33193386 未加载
评论 #33191937 未加载
janejeonover 2 years ago
I&#x27;m a little bit confused on the &quot;sorting perf improvements&quot; bit. Does that mean that if I have a query with a `SORT BY`, it will literally &quot;just be faster&quot;? Surely that sounds too good to be true...?
评论 #33191341 未加载
brunoolivover 2 years ago
Could someone give some examples on their own domains where the MERGE command is a huge QOL improvement over what&#x27;s currently available?<p>I see a lot of people being so very happy in the comments, and, well, I&#x27;ve tried to think long and hard about how to apply it to my current domain but was a bit at a loss... Maybe some practical examples can help?
评论 #33193861 未加载
评论 #33193794 未加载
评论 #33193497 未加载
xnxover 2 years ago
Glad to see all the new regex functions. I recently moved a database from AWS Redshift to Postgres on Heroku and was shocked to see how many functions like regexp_substr() weren&#x27;t available. Wish this had come sooner so I didn&#x27;t have to rewrite so many of my queries.
评论 #33191218 未加载
hardwaresoftonover 2 years ago
jsonlog looks pretty neat! Structured logging is going to make a lot of tooling much easier to write
评论 #33193195 未加载
chrstrover 2 years ago
&gt; Queries using SELECT DISTINCT can now be executed in parallel.<p>This sounds quite interesting, but I would assume it does not always work? I didn&#x27;t see this mentioned in the linked documentation, does someone know when&#x2F;how the parallel distinct works?
评论 #33191883 未加载
评论 #33192796 未加载
jfbaroover 2 years ago
Congrats PG team and community
praveenwebover 2 years ago
Interestingly, there are no breaking changes that were required to be addressed by Hasura GraphQL Engine to support Postgres 15. Hasura is fully compatible with this release, with the potential of adding the MERGE command via the GraphQL API soon.<p>Excited about the incremental performance improvements and making more secure defaults by revoking CREATE permission for public schema for non-superusers.
ppjimover 2 years ago
I hope that someday it will become as popular as MySql. Although I see complicated, since many companies use other alternatives and in my experience it is complicated to make the migration when you have many years using the same technologies.