search
HomeDatabaseMysql Tutorial你在以错误的原因看待NoSQL数据库吗?

原文地址(source):http://maurizioturatti.com/blog/2015/01/06/using-nosql-wrong-reason/ 我最近看到一篇报道,在某些条件下,PostgreSQL在很多重要地方胜过MongoDB,这让我想起了关于数据存储选择方面的、不同选项背后的理论,特别是在SQL和NoSQL解决

原文地址(source):http://maurizioturatti.com/blog/2015/01/06/using-nosql-wrong-reason/

PostgreSQL与MongoDB的性能评测

我最近看到一篇报道,在某些条件下,PostgreSQL在很多重要地方胜过MongoDB,这让我想起了关于数据存储选择方面的、不同选项背后的理论,特别是在SQL和NoSQL解决方案之间的天真比较——不幸的是,这一幕经常发生。

上面的评测由EnterpriseDB创建,EnterpriseDB是开发PostgreSQL的商业公司(因此测评可能会有一点儿偏见……),除了这个明显的事实,我已经注意到PostgreSQL是让人惊奇的产品,在这一点上,我推荐它作为亟待解决的、大部分数据存储问题的、最佳方案之一。有着非凡性能需求的知名企业都正在PostgreSQL上投入巨大。

然而,我这里的观点稍微不同:我自问,大多数公司是否正确地看待着“NoSQL”解决方案、以及性能需求是否已经成为他们急需考虑的。比如,让我们看看MongoDB词条在维基百科上的解释,它是我这些天经常在用的、一种数据库:

MongoDB是一种跨平台的面向文档的数据库。作为一种NoSQL数据库,MongoDB没有采用传统的基于表的关系型数据库结构,而是钟情于带有动态模式的类JSON文档(MongoDB称之为BSON),使得特定类型的应用程序里的数据集成更容易、更快速。

我想刻意强调句子中的“特定类型的应用程序里”,因为这恰恰就是我要说的:你不能仅仅因为性能就抛弃关系型数据库、转而采用面向文档的数据库,因为这是愚蠢的动机:一个调优的SQL数据库每秒处理的事务能够超过14000条,因此如果你超过了这个量级,说明你已经在一流的公司里了,有着首要的扩展需求:恭喜!

相反,

当实体大部分与树形结构相关,且关系模型持续被迫地创建join或重度反规范化关系而超越了其合理性时,文档数据库就是优于关系型数据库的更好的解决方案。

在这种情况下,数据模型符合上面的约束,那么面向文档结构有能力比关系型模型创建更少的、与面向对象设计不匹配的现象。据我们所知,所有重要的关系型数据库模式创建了大量的与对象模型相关的属性,这就是饱受诟病的对象关系阻抗不匹配(Object-relational impedance mismatch)问题。面向对象的系统通常是树状结构,它比其它模型能够更好地适应文档数据库,图数据库【注1】除外,很明显,图数据库实现了一个图的大部分通常表现。

在SQL领域之外,我总是建议不要低估你和团队正在失去大部分久经考验的工具和专长,你们每天都在不自觉地应用着。我看到过很多人费力地从NoSQL仓库抽出非常基本的信息,而这些信息用关系型数据库就可以容易地实现,主要是因为多年来人们都是这样做的。那么,NoSQL数据库在管理事务上,和“正统的”关系型数据库相比,有着很大的不同:用最终一致性(Eventual Consistency)和幂等服务(Idempotent Services) 设计应用程序,你知道意味着什么吗?

我不是说你不应该采用新技术,因为我和公司已经为此做了很多,但是我的最终建议是:

采用适合你的领域模型(domain model)【注2】的数据存储方案,不要过早地性能伪优化:你可能在尽量解决错误的问题。

  • 注1:图数据库也可称为面向/基于图的数据库,对应的英文是Graph database。图数据库的基本含义是以“图”这种数据结构存储和查询数据,不是存储图片的数据库。图数据库的基本存储单元为:节点、关系、属性。http://zh.wikipedia.org/wiki/%E5%9B%BE%E6%95%B0%E6%8D%AE%E5%BA%93
  • 注2:领域模型可以被看作是一个系统的概念模型,用于以可视化的形式描述系统中的各个实体及其之间的关系。领域模型记录了一个系统中的关键概念和词汇表,显示出了系统中的主要实体之间的关系,并确定了它们的重要的方法和属性。因此,对应于用例所描述的动态视图,领域模型提供了一种对整个系统的结构化的视图。领域模型的一个好处是描述并限制了系统边界。http://zh.wikipedia.org/wiki/%E9%A2%86%E5%9F%9F%E6%A8%A1%E5%9E%8B

The post 你在以错误的原因看待NoSQL数据库吗? appeared first on 腊八粥.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What are stored procedures in MySQL?What are stored procedures in MySQL?May 01, 2025 am 12:27 AM

Stored procedures are precompiled SQL statements in MySQL for improving performance and simplifying complex operations. 1. Improve performance: After the first compilation, subsequent calls do not need to be recompiled. 2. Improve security: Restrict data table access through permission control. 3. Simplify complex operations: combine multiple SQL statements to simplify application layer logic.

How does query caching work in MySQL?How does query caching work in MySQL?May 01, 2025 am 12:26 AM

The working principle of MySQL query cache is to store the results of SELECT query, and when the same query is executed again, the cached results are directly returned. 1) Query cache improves database reading performance and finds cached results through hash values. 2) Simple configuration, set query_cache_type and query_cache_size in MySQL configuration file. 3) Use the SQL_NO_CACHE keyword to disable the cache of specific queries. 4) In high-frequency update environments, query cache may cause performance bottlenecks and needs to be optimized for use through monitoring and adjustment of parameters.

What are the advantages of using MySQL over other relational databases?What are the advantages of using MySQL over other relational databases?May 01, 2025 am 12:18 AM

The reasons why MySQL is widely used in various projects include: 1. High performance and scalability, supporting multiple storage engines; 2. Easy to use and maintain, simple configuration and rich tools; 3. Rich ecosystem, attracting a large number of community and third-party tool support; 4. Cross-platform support, suitable for multiple operating systems.

How do you handle database upgrades in MySQL?How do you handle database upgrades in MySQL?Apr 30, 2025 am 12:28 AM

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

What are the different backup strategies you can use for MySQL?What are the different backup strategies you can use for MySQL?Apr 30, 2025 am 12:28 AM

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

What is MySQL clustering?What is MySQL clustering?Apr 30, 2025 am 12:28 AM

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

How do you optimize database schema design for performance in MySQL?How do you optimize database schema design for performance in MySQL?Apr 30, 2025 am 12:27 AM

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

How can you optimize MySQL performance?How can you optimize MySQL performance?Apr 30, 2025 am 12:26 AM

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.