|Running PostgreSQL Inside Your Browser
|Written by Nikos Vaggalis
|Thursday, 08 September 2022
Yes it is possible thanks to, what else, WebAssembly. And with it, the emergence of the Postgres playground, brought to us by Crunchy Data, with live-guided SQL exercises for any level.
One of PostgreSQL's engineers had a crazy idea which he has now managed to realize.The idea came from the fact that it was possible to run SQLite inside your browser, so the reasoning was could the same happen for Postgres too?
But compiling an embedded and small in size and scale
But there was a workaround. By building a v86 virtual machine based on an Alpine Linux image and installing Postgres on it,
However there's two limitations with that approach; there's no internet access from inside the VM and there's no data persistence, so changes are lost when leaving or refreshing the page.
That latter disadvantage is one they actually took advantage of, building on it to create ephemeral playgrounds that let you
The playgrond offers:
So what's the big deal? I could very well spin a Postgres instance on SQL/DB Fiddle SQL playgrounds and run my queries there, no problem. How does my local Postgres copy offer more?
For one, it is fast as it runs locally without the need to set up a VM lab. There are no restrictions which would be needed for an internet-based playground; you have control of a full instance and the full spectrum of SQL and functionality. And of course privacy since you can use your own data at your own machine.
Finally there's an extra bonus.With the news of Heroku dropping its free plans, which include the Postgres instances, having an option to run such services locally is going to be a great advantage.I don't know whether it's related to crypto mining, but other SaaS providers like CI webapp.io, GitLab, TravisCI, and Shippable are all limiting or shutting down their free tiers due to cryptocurrency mining attacks.So again, having a service running locally could prove a great alternative.
It's still early days for Postgres and WASM so there's some polishing to do, but the people at Crunchy Data are working on it.
or email your comment to: email@example.com
|Last Updated ( Thursday, 08 September 2022 )