(评论)
(comments)

原始链接: https://news.ycombinator.com/item?id=41224286

隆重推出“Postgres New”,这是由 Supabase 首席执行官开发的突破性实验服务,利用 PGLite(在浏览器中运行的 PostgreSQL 的轻量级 Web Assembly 版本)。 以前的版本约为 30MB,但 Electric 团队在保持功能的同时设法将其减少到 3MB 以下。 PGLite 采用 PostgreSQL 的单用户模式,使其能够在没有 WASM 环境中通常提供的进程分叉或线程支持的情况下运行。 这种独特的方法允许用户创建本地化的 PostgreSQL 沙箱,通过与 LLM(例如 GPT-4o)集成提供人工智能帮助,并在浏览器中提供无限的 Postgres 数据库。 显着的特点包括: 1. CSV 上传会自动创建 Postgres 表以自然查询。 2. 根据提供的数据生成图表并定制。 3. RAG/pgVector 嵌入创建以实现高效的数据可视化。 未来的计划包括通过 pg-gateway 从 Amazon 的 S3 存储系统提供这些数据库,目标是在本周末实现只读部署。 与流行的 Postgres 工具(例如 psql)的兼容性确保了无缝集成。 与该项目相关的所有内容都是开源的,特别感谢 Electric 团队。

相关文章

原文
hey HN, supabase ceo here

This is a new service that we're experimenting with that uses PGLite[0], a WASM build of Postgres that runs in the browser. You might remember an earlier WASM build[1] that was around ~30MB. The Electric team [2] have gone one step further and created a complete build of Postgres that’s under 3MB.

Their implementation is technically interesting. Postgres is normally multi-process - each client connection is handed to a child process by the postmaster process. In WASM there’s limited/no support for process forking and threads. Fortunately, Postgres has a relatively unknown built-in “single user mode” [3] primarily designed for bootstrapping a new database and disaster recovery. Single-user mode only supports a minimal cancel REPL, so PGlite adds wire-protocol support which enables parametrised queries etc.

We have created https://postgres.new as an experiment. You can think of it like a love-child between Postgres and ChatGPT: in-browser Postgres sandbox with AI assistance. You can spin up as many new Postgres databases as you want because they all live inside your browser. We pair PGlite with an LLM (currently GPT-4o) and give it full reign over the database with unrestricted permissions. This is an important detail - giving an LLM full autonomy means that it can run multiple operations back-to-back: any SQL errors from Postgres are fed back to the language model so that it can have a few more attempts to solve the problem. Since it’s in-browser it’s low risk.

Some other features include:

    - CSV upload: you can upload a CSV and it will automatically create a Postgres table which you can query with natural language.

    - Charts: you can ask the LLM to create a chart with the data and change the colors of the charts.

    - RAG / pgvector: PGLite supports pgvector, so you can ask the LLM to create embeddings for RAG. The site uses transformers.js [4] to create embeddings inside the browser.
We’re working on an update to deploy your databases and serve them from S3 using pg-gateway [5]. We expect to have a read-only deployments ready by the end of the week. You can access them using any postgres-compatible tool (eg: psql).

Everything is open source. A huge shout-out to the Electric team who have been a pleasure to build with.

[0] PGLite: https://github.com/electric-sql/pglite

[1] Postgres-wasm: https://supabase.com/blog/postgres-wasm

[2] Electric: https://electric-sql.com/

[3] Single user mode: https://www.postgresql.org/docs/current/app-postgres.html#AP...

[4] transformers.js: https://github.com/xenova/transformers.js

[5] pg-gateway: https://github.com/supabase-community/pg-gateway

联系我们 contact @ memedata.com