轻量级数据库(SQL 或 NoSQL)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10151070/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 15:19:16  来源:igfitidea点击:

Lightweight database (SQL or NoSQL)

sqldatabasememorynosql

提问by Kris

I'm currently working on a website that must exist on a VM with very low memory availability (at the moment I am told to expect 512mb). Unfortunately, at least in the immediate future, the database and web application must be the same server.

我目前正在开发一个网站,该网站必须存在于内存可用性非常低的虚拟机上(目前我被告知需要 512mb)。不幸的是,至少在不久的将来,数据库和 Web 应用程序必须是同一台服务器。

Now I've read through some questions here and tried to do my own research but there are just so many options to choose from. Essentially, what will be a light enough database server that I can install? SQL or NoSQL doesn't really matter; it won't be database intensive but I would like to not be constraint with whatever I choose now. Meaning, if possible, a path towards multi-server scaling would be great but obviously not a requirement at this stage.

现在我已经阅读了这里的一些问题并尝试做我自己的研究,但有很多选择可供选择。本质上,什么是我可以安装的足够轻的数据库服务器?SQL 或 NoSQL 并不重要;它不会是数据库密集型的,但我不想受到我现在选择的任何限制。这意味着,如果可能的话,通往多服务器扩展的道路会很棒,但在现阶段显然不是必需的。

My current thoughts are either MongoDB or MySQL but I'm not sure if those are the best choices.

我目前的想法是 MongoDB 或 MySQL,但我不确定这些是否是最佳选择。

My web application is running on nginx with PHP which I think is the best choice for now so my main concern is the database side.

我的 Web 应用程序运行在带有 PHP 的 nginx 上,我认为这是目前最好的选择,所以我主要关心的是数据库端。

采纳答案by andrew cooke

if you need the lightest-weight database i would say sqlite 3. it's purpose designed for this task, is small and fast, and in my experience is reliable and easy to use.

如果您需要最轻量级的数据库,我会说sqlite 3。它专为此任务而设计,体积小,速度快,而且根据我的经验,它可靠且易于使用。

i don't use php myself, but there appears to be support here.

我自己不使用 php,但这里似乎有支持

sqlite supports pretty much "standard" sql, except that it doesn't enforce types - you can define a column to be text, but store and retrieve an integer value, if you feel like it. in practice, it's not a big deal and as long as you don't use this "feature" you can switch to a larger database in the future with little trouble.

sqlite 支持几乎“标准”的 sql,除了它不强制类型 - 您可以将列定义为文本,但如果您愿意,可以存储和检索整数值。实际上,这没什么大不了的,只要您不使用此“功能”,将来就可以轻松切换到更大的数据库。

but, in practice, i would start with mysql since it is likely already installed and available. if it gives you issues with memory use, switch to sqlite. but for a simple, no frills database, you might as well start with mysql.

但是,在实践中,我会从 mysql 开始,因为它可能已经安装并可用。如果它给您带来内存使用问题,请切换到 sqlite。但是对于一个简单的、没有多余装饰的数据库,您不妨从 mysql 开始。

回答by Dan

When choosing between a relational database or a document-oriented database, it is best to focus on the data storage needs of the specific application. If an application better suited for a relational database is written on top of a document-oriented database such as MongoDB, it will be less efficient and consume more resources.

在关系数据库或面向文档的数据库之间进行选择时,最好关注特定应用程序的数据存储需求。如果在面向文档的数据库(如 MongoDB)之上编写更适合关系数据库的应用程序,则效率会降低并消耗更多资源。

回答by ehsan

did you see OrientDB?

你看到OrientDB 了吗?

OrientDB has the flexibility of the Document databases and the power of the Graph databases to manage relationships. It can work in schema-less mode, schema-full or a mix of both. Supports advanced features such as ACID Transactions, Fast Indexes, Native and SQL queries. It imports and exports documents in JSON.

OrientDB 具有 Document 数据库的灵活性和 Graph 数据库管理关系的能力。它可以在无模式模式、全模式或两者的混合模式下工作。支持高级功能,例如 ACID 事务、快速索引、本机和 SQL 查询。它以 JSON 格式导入和导出文档。