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.

Pg_branch: Experimental Postgres extension brings Neon-like branching

193 pointsby bx376over 1 year ago

17 comments

sverhagenover 1 year ago
I think I saw an Uber-engineer's presentation (YouTube; can't find it now anymore) about their test environment having the ability to automatically fork the database for every new test run, such that they could easily "revert" (in their case ignore/walk away from) the database after a test run. I find that an appealing idea, since regular test runs in the places where I work, tend to create cruft data in the test enviroment that is lopsided and voluminous in ways that do not properly represent the production system anymore. (And no one wants to troubleshoot performance issues that only ever exist in the test environment.) I have to imagine that pg_branch might be part of building a solution similar to this? Could people speak to some practical applications for this? Maybe I'm thinking about entirely the wrong one here...
评论 #37734600 未加载
评论 #37743884 未加载
评论 #37737777 未加载
评论 #37736322 未加载
mj4eover 1 year ago
For anyone wondering what &quot;Neon-like branching&quot; is, this is worth a read: <a href="https:&#x2F;&#x2F;neon.tech&#x2F;blog&#x2F;database-branching-for-postgres-with-neon" rel="nofollow noreferrer">https:&#x2F;&#x2F;neon.tech&#x2F;blog&#x2F;database-branching-for-postgres-with-...</a>
评论 #37791377 未加载
wdbover 1 year ago
How does this differ with Postgres AI&#x27;s thin cloning and database branching? <a href="https:&#x2F;&#x2F;github.com&#x2F;postgres-ai&#x2F;database-lab-engine">https:&#x2F;&#x2F;github.com&#x2F;postgres-ai&#x2F;database-lab-engine</a>
评论 #37745521 未加载
评论 #37738533 未加载
bhoustonover 1 year ago
Interesting that branching is now better supported and almost free. I wonder if merging can be simplified or whether it already is as simple and as fast as it can be?<p>I guess I am inspired by Dolt’s ability to branch and merge: <a href="https:&#x2F;&#x2F;github.com&#x2F;dolthub&#x2F;dolt">https:&#x2F;&#x2F;github.com&#x2F;dolthub&#x2F;dolt</a>
评论 #37735438 未加载
skeptruneover 1 year ago
Holy hell this thing is awesome. I am incredibly surprised at how little code it took to achieve a MVP on this. Adding this to local docker image would make doing so many things easier during testing and local dev.<p>Having it on CI actions would also be amazing.
orangepurpleover 1 year ago
Don&#x27;t use BTRFS! I <i>still</i> encounter crippling data loss and error messages in my dmesg log after giving it another shot for the last 10 months. I try btrfs with Arch Linux every few years because of its native transparent compression abilities. Enough is enough! Just say no. Friends don&#x27;t let friends use btrfs.<p>bcachefs is the only hope left for normal Linux users but it has not landed yet. I am using ZFS for &#x2F;home (with zstd compression) on LVM on LUKS and my root partition is ext4 on LVM on LUKS.<p>I considered VDO for LVM because it supports compression but VDO IS A JOKE! <a href="https:&#x2F;&#x2F;github.com&#x2F;dm-vdo&#x2F;vdo&#x2F;issues&#x2F;38">https:&#x2F;&#x2F;github.com&#x2F;dm-vdo&#x2F;vdo&#x2F;issues&#x2F;38</a>
评论 #37739195 未加载
zoomzoomover 1 year ago
If interested in using Neon for ephemeral environments, Coherence (I’m a cofounder) recently launched a first-class integration with Neon for just this purpose: <a href="https:&#x2F;&#x2F;docs.withcoherence.com&#x2F;docs&#x2F;reference&#x2F;integrations#neon" rel="nofollow noreferrer">https:&#x2F;&#x2F;docs.withcoherence.com&#x2F;docs&#x2F;reference&#x2F;integrations#n...</a><p>Would be cool to try using this extension on top of RDS or Cloud SQL to offer the same experience without the overhead of another SaaS tool!
nalexpearover 1 year ago
Author here: thanks for taking a look at pg_branch! I didn&#x27;t expect to have this posted to HN today, but I&#x27;m happy to answer any questions folks have about it.
curt15over 1 year ago
Doesn&#x27;t btrfs suffer crippling performance penalties for DBs unless you disable its marquee features of copy-on-write and checksumming?
评论 #37745550 未加载
评论 #37740395 未加载
评论 #37739504 未加载
mrinterwebover 1 year ago
One thing I could see where this could be useful would be unit test suites where you want different sets of seed data, but you want to be sure that each test doesn&#x27;t accidentally mutate and leak state to other tests. There are other ways to do this, but this seems like it might be a natural fit for isolating persistence changes.
mrinterwebover 1 year ago
I see APFS (MacOS default file system) supports copy-on-write. I wonder if there are plans for pg_branch to support apfs.
jsmith99over 1 year ago
For ad hoc copies I’ve found the third party schema cloning function useful. I assume performance would be an issue for huge databases though. <a href="https:&#x2F;&#x2F;github.com&#x2F;denishpatel&#x2F;pg-clone-schema">https:&#x2F;&#x2F;github.com&#x2F;denishpatel&#x2F;pg-clone-schema</a>
评论 #37739613 未加载
nextaccounticover 1 year ago
I once saw another extension, or product on top of postgres, that achieved copy-on-write semantics (and I think it didn&#x27;t require a fs with snapshots like btrfs). It wasn&#x27;t pg_branch or pgcow. Does anyone heard of something like this?
评论 #37738423 未加载
vb-8448over 1 year ago
Really cool, I&#x27;ve implemented something similar for MySQL on top of Ubuntu and LVM snapshots. With a very low space overhead, we were able to create tens of copies of the main database for development purpose.
imiricover 1 year ago
This is neat, but I wouldn&#x27;t trust BTRFS for any serious usage. I&#x27;ve read way too many data loss reports to make me stay away even for personal use.<p>Could this work on ZFS, or a layered FS like Aufs&#x2F;OverlayFS?
评论 #37735988 未加载
评论 #37735517 未加载
评论 #37738008 未加载
baqover 1 year ago
Remind me why macOS is the best development OS again...? This has the potential to 2x my debug speed when bisecting test failures and testing fixes. Wonder what corporate IT will say if they see me doing real work on a Linux vm, I&#x27;m <i>very</i> tempted to check.<p>Edit: quick google tells me APFS supports snapshots&#x2F;cow, could the same approach be used here?
评论 #37735138 未加载
klysmover 1 year ago
For tests in Postgres you can kind of do something similar by creating template databases