如果使用得当,MySQL也可以化身NoSQL
随着互联网和移动互联网的发展,各个机构都需要支撑远超过以往的数据。而在这个需求的刺激下,IT领域出现了大量数据处理技术,其
【编者按】随着互联网和移动互联网的发展,各个机构都需要支撑远超过以往的数据。而在这个需求的刺激下,IT领域出现了大量数据处理技术,其中之一就是 NoSQL。灵活的数据类型,,高效的处理能力,让NoSQL已占据数据管理系统的一席之地,比如人气NoSQL数据库MongoDB。然而在Wix工程实践中,他们发现,大量场景中其实并不需要NoSQL,反而成熟的RDBMS更具效益,比如MySQL。下面一起看Wix工程主管 Aviran Mordo的分享,由 OneAPM工程 师翻译。
以下为译文
开发人员选择NoSQL数据库一般都是根据主观臆断,或者“关系型数据库性能不如NoSQL数据库”这个错误的理念。此外,在做数据库选型时,开发人员往往还忽视了运维上的开销。实际上根据Wix的实践发现,大部分情况下都不必去选择NoSQL数据库,而且如果使用得当的话,MySQL也可以是一个优秀的NoSQL数据库。
在可扩展系统构建时,一个很重要的考量是使用的技术是否成熟,选择成熟的技术意味着出错时能够迅速恢复。当然,开发者也可以在项目中使用最新最牛的NoSQL数据库,而这个数据库在理论上也可以良好地运行,然而在生产环境中出现了问题恢复需要多久?技术上已有的知识和经验积累对于问题缓解至关重要,当然这个积累也包括了Google可以搜索到的内容。相比之下,关系型数据库已经存在了超过四十年,业界对于关系型数据库的维护也积累了大量的经验。基于这些考虑,在新项目做技术选型时通常会选择MySQL,而不是NoSQL数据库,除非NoSQL真的有非常非常明显的优势,比如数据量太大就不适合使用MySQL。
必须承认MySQL也有自己的问题。在大规模系统中使用的话可能会碰到性能上的问题。为实现MySQL性能的最优化,这里总结了几条经验,其中之一是避免数据库级别的事务。因为事务需要数据库采用锁来实现,从而会影响数据库性能。通常情况下会使用逻辑应用程序级的锁来 替换,从而减少负载并获得一个更好的性能。
举个例子,以发票结构为例。如果某个发票有多个行项目,取代在单事务将所有行项目写入,这里更应该在非事务情况下逐行写入。在所有行全部写入数据库后,这里还会写入一个首记录,它包含了指向所有行项目ID的指针。这样一来,如果所有行中有一行写入失败,那么这行的首记录就会不存在,从而整个事务失败。这么做虽然可能会造成一些垃圾记录,但在存储介质如此便宜的今天这显然不是什么大问题,而这些垃圾记录也可以做定期删除。
下面也中介了一些MySQL实践经验:
在Wix,MySQL经常会被当做键值存储,比如在一列中储存JSON对象,从而在不改变数据库模式下对数据结构模式进行扩展。在MySQL 中,使用主键读取也很快,Wix就通过这个方式获得了亚毫秒级的读取速度,完全可以支撑整个使用场景。基于以上这些原因,MySQL完全可以看作一个符合 ACID原则的NoSQL数据库。至于数据库的大小,一个MySQL实例支持几亿条数据是没什么问题的。
关系型数据库的一个鲜明的优势是不用考虑最终一致性,而这个在NoSQL数据库中并不是原生支持的。本文也不是贬低NoSQL,因为关系型数据库已有限制也非常多:严格的数据结构和大小限制。这里只是想提醒开发人员,在选择新技术时不要忽视运维成本。
原文链接: MySQL is a Great NoSQL Database (责编/仲浩)
本文永久更新链接地址:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

With the development of the Internet, big data analysis and real-time information processing have become an important need for enterprises. In order to meet such needs, traditional relational databases no longer meet the needs of business and technology development. Instead, using NoSQL databases has become an important option. In this article, we will discuss the use of SpringBoot integrated with NoSQL databases to enable the development and deployment of modern applications. What is a NoSQL database? NoSQL is notonlySQL

In modern web application development, PHP and NoSQL databases have become very popular technology choices. In the past, PHP has been widely used to develop dynamic websites and web applications, while NoSQL database is a new data storage technology that has only recently emerged, providing a more flexible and scalable solution. In this article, we will explore PHP and NoSQL databases in practical applications. PHP is a server-side programming language, originally

PrimeFactor−Innumbertheory,theprimefactorsofapositiveintegeraretheprimenumbersthatdividethatintegerexactly.Theprocessoffindingthesenumbersiscalledintegerfactorization,orprimefactorization.Example−Primefactorsof288are:288=2x2x2x2x2

In 2025, global digital virtual currency trading platforms are fiercely competitive. This article authoritatively releases the top ten digital virtual currency trading platforms in the world in 2025 based on indicators such as transaction volume, security, and user experience. OKX ranks first with its strong technical strength and global operation strategy, and Binance follows closely with high liquidity and low fees. Platforms such as Gate.io, Coinbase, and Kraken are at the forefront with their respective advantages. The list covers trading platforms such as Huobi, KuCoin, Bitfinex, Crypto.com and Gemini, each with its own characteristics, but investment should be cautious. To choose a platform, you need to consider factors such as security, liquidity, fees, user experience, currency selection and regulatory compliance, and invest rationally

NoSQL (NotOnlySQL) database is a type of database that has developed rapidly in recent years. Compared with traditional relational databases, it has better scalability and performance, and supports more data types and data storage methods. Among them, MongoDB is a NoSQL database that uses the document database model and is widely used in web applications, mobile applications, Internet of Things devices and other fields. This article will introduce how to use PHP to write the basic operations of MongoDB database, and demonstrate through examples how to meet

Top 10 digital currency trading platforms: 1. OKX, 2. Binance, 3. Gate.io, 4. Huobi Global, 5. Kraken, 6. Coinbase, 7. KuCoin, 8. Bitfinex, 9. Crypto.com, 10. Gemini, these exchanges have their own characteristics, and users can choose the platform that suits them based on factors such as security, fees, currency selection, user interface and customer support.

Ranking of the top ten virtual currency trading platforms (latest in 2025): Binance: Global leader, high liquidity, and regulation has attracted attention. OKX: Large user base, supports multiple currencies, and provides leveraged trading. Gate.io: A senior exchange, with a variety of fiat currency payment methods, providing a variety of trading pairs and investment products. Bitget: Derivatives Exchange, high liquidity, low fees. Huobi: An old exchange that supports a variety of currencies and trading pairs. Coinbase: A well-known American exchange, strictly regulated. Phemex and so on.

This article recommends ten digital currency trading apps: 1. OKX; 2. Binance; 3. Gate.io; 4. Huobi Global; 5. Kraken; 6. Coinbase; 7. KuCoin; 8. Crypto.com; 9. Bitfinex; 10. Poloniex. When choosing a platform, you need to consider factors such as security, liquidity, transaction fees, currency selection, user interface, customer service support and regulatory compliance, and carefully evaluate risks and never blindly follow the trend.
