PostgreSQL作为嵌入式数据库。

huangapple go评论79阅读模式
英文:

postgresql as an embedded Database

问题

关于嵌入式PostgreSQL版本的小帮助。我看到我们可以创建嵌入式形式的PostgreSQL链接。但页面上主要说明了一个面向测试的库,没有说明它是否可以用于生产环境。需求是存储一些JSON数据,这些数据太大无法完全放入内存,而完整的数据库会太慢。很好地在函数运行期间启动数据库,完成后关闭数据库看起来是个不错的折衷方案。PostgreSQL还提供了本地JSON处理,如果可以使用的话,将提供许多优势。我还看到没有官方的嵌入式PostgreSQL版本。这能在生产环境中使用吗?

英文:

Need a small help regarding the embedded version of PostgreSql. I see that we can create an embedded form of PostgreSql https://github.com/zonkyio/embedded-database-spring-test . But the page specifies mostly a test oriented library and it does not specify if this can be used in a production environment. The requirement is to store some JSON data that will be too large for memory and having a full fledged DB will be too slow. It is good to have a DB spun up for the duration of the function and kill it once the function is complete. So having an embedded version of DB seemed like a good trade off. PostgreSql also provides native JSON handling which provides a lot of advantages if it can be used. I also see that there is no official embedded version of postgresql. Can this be used in the production environment?

答案1

得分: 1

I wouldn't.

如果你只需要一个短期的嵌入式数据库,我建议看看sqlite(它支持JSON,但我不知道它是否符合你的要求),或者使用文件作为后端机制的h2。你还可以看看RocksDB,但它更底层。

Sqlite和RocksDB被许多产品使用。我确信h2偶尔也被使用,但可能远远不如前两者。

你还需要考虑你的服务存储方式,以确定IOPS是否足够(在机械硬盘上运行将与nvme上运行非常不同)。

英文:

I wouldn't.

If you need an embedded DB for a short duration I would recommend taking a look at sqlite (which supports json, but I don't know if it fits your requirements), or h2 using a file as the backing mechanism. You could also take a look at RocksDB, but that is a lot lower level.

Sqlite and RocksDb are used by many products. I'm sure h2 is used here and there but probably to a far lower extent.

You'll also need to think about the storage of your service to find out if the IOPS are good enough (running on mechanical drives will be very different from nvme).

huangapple
  • 本文由 发表于 2023年2月27日 16:28:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/75578229.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定