TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Pg_CRDT – CRDTs in Postgres Using Automerge

11 点作者 kiwicopple大约 1 个月前

2 条评论

marcprux大约 1 个月前
Are there plans to add support in your client libraries like <a href="https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;supabase-swift">https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;supabase-swift</a>?<p>And could this be used as backend support for <a href="https:&#x2F;&#x2F;github.com&#x2F;drewmccormack&#x2F;Forked">https:&#x2F;&#x2F;github.com&#x2F;drewmccormack&#x2F;Forked</a>?
评论 #43657497 未加载
kiwicopple大约 1 个月前
A couple of years ago we shared[0] an experimental extension for CRDTs in Postgres. This was a good start, but it had a major limitation: CRDTs can be very chatty and so they quickly fill up the WAL.<p>We just released a new version which solves this problem: <a href="https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_crdt">https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_crdt</a><p>The new approach uses UNLOGGED tables for documents and logged tables for changes. This enables us to merge changes efficiently in-memory, then persists just the changes directly to the WAL (previously it was sending the entire CRDT).<p>The new version also takes advantage an advanced in-memory object persistence feature in Postgres called &quot;expanded datum&quot;[1] and some optimizations to this feature that are coming in Postgres 18[2]. This allows for more complex operations without serializing and deserializing the documents between every operation, which gets progressively slower as documents grow.<p>What is a CRDT? A CRDT (Conflict-free Replicated Data Type) is a data structure that syncs across multiple devices or users. They are used in multi-player applications like Figma and Notion. For example: A shared text editor where multiple people type at once, and everyone sees the same final result without manual conflict resolution.<p>The end goal here is that you will be able to store CRDTs as a data type in your database, and treat Postgres simply as a &quot;peer&quot;. A good example would be storing text for a blog post:<p><pre><code> create table posts ( id serial primary key, title text not null content autodoc not null default &#x27;{}&#x27; ); </code></pre> Repo: <a href="https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_crdt">https:&#x2F;&#x2F;github.com&#x2F;supabase&#x2F;pg_crdt</a><p>Docs: <a href="https:&#x2F;&#x2F;supabase.github.io&#x2F;pg_crdt&#x2F;automerge&#x2F;" rel="nofollow">https:&#x2F;&#x2F;supabase.github.io&#x2F;pg_crdt&#x2F;automerge&#x2F;</a><p>----<p>[0] initial release&#x2F;discussion: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33931971">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33931971</a><p>[1] expanded datum: <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;storage-toast.html#STORAGE-TOAST-INMEMORY" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;storage-toast.html#S...</a><p>[2] PG18 optimizations: <a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;message-id&#x2F;3363452.1737483125%40sss.pgh.pa.us" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;message-id&#x2F;3363452.1737483125%40s...</a>
评论 #43656102 未加载