frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

What if we treated Postgres like SQLite?

https://www.maragu.dev/blog/what-if-we-treated-postgres-like-sqlite
41•markusw•3h ago

Comments

emschwartz•2h ago
I think this is a neat direction to explore. I've wondered in the past whether you could use https://pglite.dev/ as if it were SQLite.
thruflo•1h ago
This is very much the point of https://pglite.dev

It's an embeddable Postgres you can run in process as a local client DB, just like SQLite but it's actually Postgres.

OutOfHere•1h ago
I wish this were available for Go lang, perhaps via Wazero.
ncruces•23m ago
Me too. There's only so much time in life. I'd take it for a spin if someone else did it. :)
emschwartz•40m ago
For sure. I’m curious if anyone using it in production as an alternative to SQLite and, if so, what the performance and experience is like.
tensor•1h ago
Someone is working on a libpglite based around pglite. I think this is what will provide an actual sqlite alternative:

https://github.com/electric-sql/pglite-bindings

It would still be missing the standardized disk format aspect of sqlite, but otherwise will be neat.

marcobambini•2h ago
Instead of sqlite-vec you can take a look at the new sqlite-vector extension: https://substack.com/home/post/p-172465902
whartung•1h ago
I don’t recall the mechanics but I do know that folks have bundled starting a local instance of PG solely for unit tests.

There’s a pre-install step to get PG on the machine, but once there, the testing framework stands it up, and shuts it down. As I recall it was pretty fast.

nullzzz•26m ago
This is IMO best done running pg in a container using docker-compose or similar
mutagen•1h ago
Some apps do, the most used I know of is Blackmagic's Davinci Resolve, the video editor with a relatively full featured free edition available. I think this has more to do with its roots being in a high end networked environment but still, the local desktop version installs Postgres.
munchlax•1h ago
From what I've read about it, DuckDB comes close. Regular files, like sqlite, but pg functionality.
OutOfHere•1h ago
If I am not mistaken, DuckDB is suitable for columnar analytics queries, less so for multi-column row extractions. Which PG-like functionality does it offer on top?
datadrivenangel•27m ago
DuckDB does aim to be Postgres compatible from a SQL syntax perspective, but you are 100% correct that it is not optimized for individual transactions. I'm a huge advocate of DuckDB, but strongly consider your life choices if you want to use it as a transactional database.
nullzzz•27m ago
No it’s not ”pg functionality”. It’s close to SQL standard compliance but not close to what Postgres has to offer. Also, single transaction writing at a time, in-process etc.
reactordev•1h ago
electricsql...?

https://electric-sql.com/

OutOfHere•1h ago
SQLite is used more in resource-constrained environments. If I had much memory to waste, I would've used a local PostgreSQL installation to begin with.

Note that advanced vector-embedding querying techniques for approximate nearest neighbor search inevitably always need an absurd amount of memory, so it typically doesn't make sense to use them in a resource-constrained environment to begin with.

yndoendo•1h ago
I have used SQLite with embedded 2MB flash and 8MB RAM. The microSD card was used as swap for producing reports and serving them over HTTP.

Next embedded model version moved to 8MB flash and 64MB RAM with the same software infrastructure.

markusw•56m ago
It's also used plenty in the cloud, for a variety of reasons. Check out the first linked article for something I wrote on that: https://www.maragu.dev/blog/go-and-sqlite-in-the-cloud
nullzzz•1h ago
TLDR: a dude ponders if postgres could be used instead of sqlite. Close to zero useful information, no learnings from serious production use.
bob1029•1h ago
I think this is a great idea for testing. MSSQL has LocalDB which is used a lot throughout the .NET ecosystem:

https://learn.microsoft.com/en-us/sql/database-engine/config...

For heavy duty production use (i.e., pushing the actual HW limits), I would feel more comfortable with the SQLite vertical. Unix sockets are fast, but you are still going across process boundaries. All of SQLite can be ran on the same thread as the rest of the application. This can dramatically reduce consumption of memory bandwidth, etc.

bluGill•1h ago
Memory bandwidth I don't worry about much - most of the time you should settup a small database with just enough data for that test, which hopefully is fast. However sockets and processes are a worry as starting as there are places things can go wrong not related to your test and then you have flakely tests nobody trusts.
nu11ptr•1h ago
You can, just embed it in your Go app:

https://github.com/fergusstrange/embedded-postgres

tptacek•1h ago
This just runs Postgres as a process, right?
nu11ptr•1h ago
Yes, but it embeds it in your executable so it is transparent to the end user.

UPDATE: Actually, I see it is downloaded (and I think cached?). I can't recall if you can embed as an option or not.

OutOfHere•1h ago
Does this use an external binary or CGO or Wazero (Wasm) or is it rewritten in Go?

With SQLite, although all approaches are available, my fav is to use https://github.com/ncruces/go-sqlite3 which uses Wazero.

I try to avoid CGO if I can because it adds compile-time complexity, making it unfriendly for a user to compile.

nu11ptr•1h ago
> Does this use an external binary or CGO or Wazero (Wasm) or is it rewritten in Go?

Since Postgres is always a network connection, I don't believe any CGo is required.

> I try to avoid CGO if I can because it adds compile-time complexity, making it unfriendly for a user to compile.

Using zig as your C compiler mostly fixes this, but you can't 100% get rid of the complexity, but I've cross compiled using Zig cc to Windows/Mac/Linux pretty easily via CGo.

kissgyorgy•1h ago
The huge advantage of SQLite is not that it's on the same machine, but it's that is it in process which makes deployment and everything else just simpler.
tptacek•1h ago
You'd still be incurring client/server IPC for individual database queries, which would cost you one of the benefits of using SQLite (IDGAF-queries that just hammer tables repeatedly because there's almost no cost to doing so).
eirikbakke•1h ago
The PostgreSQL data directory format is not very stable or portable. You can't just ZIP it up and move it to a different machine, unless the new machine has the same architecture and "sufficiently" similar PostgreSQL binaries.

In theory the data directory works with any PostgreSQL binaries from the same major version of PostgreSQL, but I have seen cases where this fails e.g. because the binaries were from the same major version but compiled with different build options.

freedomben•39m ago
I've been hit by this too, so definitely a risk. I've also had permissions on the files get broken which is a bitch to debug
tracker1•14m ago
Yeah, I was going to mention, just upgrading between PG versions can be a bit of a pain. Dump/Restore really seems like a less than stellar option of you have a LOT of data. I mean you can stream through gzip/bzip to save space but still.

I often wish that Firebird had a license that people found friendlier to use as it always felt like a perfect technical option for many use cases from embedded to a standalone server. PG has clearly eclipsed it at this point though.

oulipo2•5m ago
So the alternative would be to just pg_dump / pg_restore the content? Is it an issue?
8organicbits•41m ago
I do this using the Docker approach, especially for low scale web apps that run on a single VM. I like that its full Postgres versus the sometimes odd limits of SQLite. My usual approach uses a Trafik container for SSL, Django+gunicorn web app, and Postgres container; all running as containers one VM. Postgres uses a volume, which I back up regularly. For testing I use `eatmydata` which turns off sync, and speeds up test cycles by a couple percent.

I haven't tried the unix socket approach, I suppose I should try, but it's plenty performant as is. One project I built using this model hit the HN front page. Importantly, the "marketing page" was static content on a CDN, so the web app only saw users who signed up.

JodieBenitez•22m ago
> You can just install Postgres on your single big and beefy application server (because there’s just the one when you use SQLite, scaled vertically), and run your application right next to it.

Am I getting old ? Seems obvious to me.

srameshc•12m ago
When I want to treat my Postgres like SQLite , I use DuckDB using PostgreSQL Extension https://duckdb.org/docs/stable/core_extensions/postgres.html and this is one of may extensions, there is more and I love DuckDB for that

OpenAI and Nvidia Announce Partnership to Deploy 10GW of Nvidia Systems

https://openai.com/index/openai-nvidia-systems-partnership/
87•meetpateltech•1h ago•94 comments

PlanetScale for Postgres is now GA

https://planetscale.com/blog/planetscale-for-postgres-is-generally-available
143•munns•2h ago•57 comments

The American nations across North America

https://colinwoodard.com/new-map-the-american-nations-regions-across-north-america/
37•loughnane•1h ago•35 comments

Cloudflare is sponsoring Ladybird and Omarchy

https://blog.cloudflare.com/supporting-the-future-of-the-open-web/
313•jgrahamc•4h ago•209 comments

SWE-Bench Pro

https://github.com/scaleapi/SWE-bench_Pro-os
21•tosh•1h ago•5 comments

A simple way to measure knots has come unraveled

https://www.quantamagazine.org/a-simple-way-to-measure-knots-has-come-unraveled-20250922/
59•baruchel•2h ago•19 comments

Mentra (YC W25) Is Hiring to build smart glasses

1•caydenpiercehax•19m ago

Cap'n Web: a new RPC system for browsers and web servers

https://blog.cloudflare.com/capnweb-javascript-rpc-library/
125•jgrahamc•4h ago•48 comments

A New Internet Business Model?

https://blog.cloudflare.com/cloudflare-2025-annual-founders-letter/
133•mmaia•2h ago•117 comments

Easy Forth (2015)

https://skilldrick.github.io/easyforth/
131•pkilgore•5h ago•76 comments

CompileBench: Can AI Compile 22-year-old Code?

https://quesma.com/blog/introducing-compilebench/
85•jakozaur•4h ago•21 comments

What is algebraic about algebraic effects?

https://interjectedfuture.com/what-is-algebraic-about-algebraic-effects/
39•iamwil•2h ago•11 comments

What if we treated Postgres like SQLite?

https://www.maragu.dev/blog/what-if-we-treated-postgres-like-sqlite
43•markusw•3h ago•37 comments

How I, a beginner developer, read the tutorial you, a developer, wrote for me

https://anniemueller.com/posts/how-i-a-non-developer-read-the-tutorial-you-a-developer-wrote-for-...
733•wonger_•15h ago•338 comments

The Strange Tale of the Hotchkiss

https://www.edrdg.org/~jwb/mondir/hotchkiss.html
7•rwmj•1d ago•0 comments

SGI demos from long ago in the browser via WASM

https://github.com/sgi-demos
187•yankcrime•9h ago•49 comments

Anti-*: The Things We Do but Not All the Way

https://blog.jim-nielsen.com/2025/my-antis/
25•gregwolanski•2h ago•10 comments

Human-Oriented Markup Language

https://huml.io/
19•vishnukvmd•1h ago•14 comments

A board member's perspective of the RubyGems controversy

https://apiguy.substack.com/p/a-board-members-perspective-of-the
12•janpio•55m ago•4 comments

Dear GitHub: no YAML anchors, please

https://blog.yossarian.net/2025/09/22/dear-github-no-yaml-anchors
132•woodruffw•2h ago•100 comments

Beyond the Front Page: A Personal Guide to Hacker News

https://hsu.cy/2025/09/how-to-read-hn/
107•firexcy•7h ago•55 comments

UK Millionaire exodus did not occur, study reveals

https://taxjustice.net/press/millionaire-exodus-did-not-occur-study-reveals/
150•mooreds•1h ago•129 comments

A Beautiful Maths Game

https://sinerider.com/
65•waonderer•2d ago•18 comments

Kmart's use of facial recognition to tackle refund fraud unlawful

https://www.oaic.gov.au/news/media-centre/18-kmarts-use-of-facial-recognition-to-tackle-refund-fr...
207•Improvement•6h ago•187 comments

Emerald Source Code Commentary

https://0xabad1dea.github.io/emeraldscc/
10•todsacerdoti•3d ago•2 comments

You did this with an AI and you do not understand what you're doing here

https://hackerone.com/reports/3340109
853•redbell•9h ago•407 comments

Privacy and Security Risks in the eSIM Ecosystem [pdf]

https://www.usenix.org/system/files/usenixsecurity25-motallebighomi.pdf
229•walterbell•12h ago•120 comments

Biconnected components

https://emi-h.com/articles/bcc.html
38•emih•18h ago•13 comments

Show HN: Software Freelancers Contract Template

https://sopimusgeneraattori.ohjelmistofriikit.fi/?lang=en
114•baobabKoodaa•9h ago•39 comments

The death rays that guard life

https://worksinprogress.co/issue/the-death-rays-that-guard-life/
43•ortegaygasset•4d ago•32 comments