Home Database Mysql Tutorial MySQL与PostgreSQL:该选择哪个开源数据库?

MySQL与PostgreSQL:该选择哪个开源数据库?

Jun 07, 2016 pm 05:34 PM
postgresql

Naresh Kumar是一位软件工程师与热情的博主,对编程与新事物充满了激情和兴趣。近日,Naresh撰写了一篇博文,对开源世界最常见的

Naresh Kumar是一位软件工程师与热情的博主,对编程与新事物充满了激情和兴趣。近日,Naresh撰写了一篇博文,对开源世界最常见的两种数据库MySQL与PostgreSQL的特点进行了详尽的分析和比对。

如果打算为项目选择一款免费、开源的数据库,那么你可能会在MySQL与PostgreSQL之间犹豫不定。MySQL与PostgreSQL都是 免费、开源、强大、且功能丰富的数据库。你主要的问题可能是:哪一个才是最好的开源数据库,MySQL还是PostgreSQL呢?该选择哪一个开源数据 库呢?

在选择数据库时,你所做的是个长期的决策,因为后面如果再改变决定将是非常困难且代价高昂的。你希望一开始就选择正确。两个流行的开源数据库MySQL与PostgreSQL常常成为最后要选择的产品。对这两个开源数据库的高层次概览将会有助于你选择最适合自己需要的。

MySQL

MySQL相对来说比较年轻,,首度出现在1994年。它声称自己是最流行的开源数据库。MySQL就是LAMP(用于Web开发的软件包,包括 Linux、Apache及Perl/PHP/Python)中的M。构建在LAMP栈之上的大多数应用都会使用MySQL,包括那些知名的应用,如 WordPress、Drupal、Zend及phpBB等。

一开始,MySQL的设计目标是成为一个快速的Web服务器后端,使用快速的索引序列访问方法(ISAM),不支持ACID。经过早期快速的发展之 后,MySQL开始支持更多的存储引擎,并通过InnoDB引擎实现了ACID。MySQL还支持其他存储引擎,提供了临时表的功能(使用MEMORY存 储引擎),通过MyISAM引擎实现了高速读的数据库,此外还有其他的核心存储引擎与第三方引擎。

MySQL的文档非常丰富,有很多质量不错的免费参考手册、图书与在线文档,还有来自于Oracle和第三方厂商的培训与支持。

MySQL近几年经历了所有权的变更和一些颇具戏剧性的事件。它最初是由MySQL AB开发的,然后在2008年以10亿美金的价格卖给了Sun公司,Sun公司又在2010年被Oracle收购。Oracle支持MySQL的多个版 本:Standard、Enterprise、Classic、Cluster、Embedded与Community。其中有一些是免费下载的,另外一 些则是收费的。其核心代码基于GPL许可,对于那些不想使用GPL许可的开发者与厂商来说还有商业许可可供使用。

现在,基于最初的MySQL代码还有更多的数据库可供选择,因为几个核心的MySQL开发者已经发布了MySQL分支。最初的MySQL创建者之一 Michael "Monty" Widenius貌似后悔将MySQL卖给了Sun公司,于是又开发了他自己的MySQL分支MariaDB,它是免费的,基于GPL许可。知名的 MySQL开发者Brian Aker所创建的分支Drizzle对其进行了大量的改写,特别针对多CPU、云、网络应用与高并发进行了优化。

PostgreSQL

PostgreSQL标榜自己是世界上最先进的开源数据库。PostgreSQL的一些粉丝说它能与Oracle相媲美,而且没有那么昂贵的价格和傲慢的客服。它拥有很长的历史,最初是1985年在加利福尼亚大学伯克利分校开发的,作为Ingres数据库的后继。

PostgreSQL是完全由社区驱动的开源项目,由全世界超过1000名贡献者所维护。它提供了单个完整功能的版本,而不像MySQL那样提供了 多个不同的社区版、商业版与企业版。PostgreSQL基于自由的BSD/MIT许可,组织可以使用、复制、修改和重新分发代码,只需要提供一个版权声 明即可。

可靠性是PostgreSQL的最高优先级。它以坚如磐石的品质和良好的工程化而闻名,支持高事务、任务关键型应用。PostgreSQL的文档非 常精良,提供了大量免费的在线手册,还针对旧版本提供了归档的参考手册。PostgreSQL的社区支持是非常棒的,还有来自于独立厂商的商业支持。

数据一致性与完整性也是PostgreSQL的高优先级特性。PostgreSQL是完全支持ACID特性的,它对于数据库访问提供了强大的安全性 保证,充分利用了企业安全工具,如Kerberos与OpenSSL等。你可以定义自己的检查,根据自己的业务规则确保数据质量。在众多的管理特性 中,point-in-time recovery(PITR)是非常棒的特性,这是个灵活的高可用特性,提供了诸如针对失败恢复创建热备份以及快照与恢复的能力。但这并不是 PostgreSQL的全部,项目还提供了几个方法来管理PostgreSQL以实现高可用、负载均衡与复制等,这样你就可以使用适合自己特定需求的功能 了。

平台

MySQL与PostgreSQL都出现在一些高流量的Web站点上:

  • MySQL:Slashdot、Twitter、Facebook与Wikipedia

  • PostgreSQL:Yahoo使用了一个修改的PostgreSQL数据库来处理每天数以亿计的事件,还有Reddit和Disqus

  • MySQL与PostgreSQL都能运行在多个操作系统上,如Linux、Unix、Mac OS X与Windows。他们都是开源、免费的,因此测试他们时的唯一代价就是你的时间与硬件。他们都很灵活且具有可伸缩性,可用在小型系统和大型分布式系统 上。MySQL在一个领域上要比PostgreSQL更进一步,那就是它的触角延伸到了嵌入式领域,这是通过libmysqld实现的。 PostgreSQL不支持嵌入式应用,依然坚守在传统的客户端/服务器架构上。

    MySQL通常被认为是针对网站与应用的快速数据库后端,能够进行快速的读取和大量的查询操作,不过在复杂特性与数据完整性检查方面不太尽如人意。 PostgreSQL是针对事务型企业应用的严肃、功能完善的数据库,支持强ACID特性和很多数据完整性检查。他们二者都在某些任务上具有很快的速 度,MySQL不同存储引擎的行为有较大差别。MyISAM引擎是最快的,因为它只执行很少的数据完整性检查,适合于后端读操作较多的站点,不过对于包含 敏感数据的读/写数据库来说就是个灾难了,因为MyISAM表最终可能会损坏。MySQL提供了修复MySQL表的工具,不过对于敏感数据来说,支持 ACID特性的InnoDB则是个更好的选择。

    与之相反,PostgreSQL则是个只有单一存储引擎的完全集成的数据库。你可以通过调整postgresql.conf文件的参数来改进性能,也可以调整查询与事务。PostgreSQL文档对于性能调优提供了非常详尽的介绍。

    MySQL与PostgreSQL都是高可配置的,并且可以针对不同的任务进行相应的优化。他们都支持通过扩展来添加额外的功能。

    一个常见的误解就是MySQL要比PostgreSQL更容易学习。关系数据库系统都是非常复杂的,这两个数据库的学习曲线其实是差不多的。

    标准兼容性

    PostgreSQL旨在实现SQL兼容性(当前标准是ANSI-SQL:2008)。MySQL则兼容大部分SQL,不过还有自己的扩展,可以支 持NoSQL特性,这在参考手册中都有介绍。每种方式都有优缺点。兼容标准会让数据库管理员、数据库开发者与应用开发者更舒服一些,因为这意味着他们只需 学习一套标准、一套特性和命令即可。这会节省时间,提升效率,也不会被锁定在特定的厂商上。

    Statement of this Website
    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

    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

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Repo: How To Revive Teammates
    4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
    Hello Kitty Island Adventure: How To Get Giant Seeds
    3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    Zend Studio 13.0.1

    Zend Studio 13.0.1

    Powerful PHP integrated development environment

    Dreamweaver CS6

    Dreamweaver CS6

    Visual web development tools

    SublimeText3 Mac version

    SublimeText3 Mac version

    God-level code editing software (SublimeText3)

    MySQL and PostgreSQL: Best Practices in Web Development MySQL and PostgreSQL: Best Practices in Web Development Jul 14, 2023 pm 02:34 PM

    MySQL and PostgreSQL: Best Practices in Web Development Introduction: In the modern world of web development, databases are an essential component. When choosing a database, common choices are MySQL and PostgreSQL. This article will cover best practices for using MySQL and PostgreSQL in web development and provide some code examples. 1. Applicable scenarios MySQL is suitable for most web applications, especially those that require high performance, scalability and ease of use.

    MySQL and PostgreSQL: Performance comparison and optimization tips MySQL and PostgreSQL: Performance comparison and optimization tips Jul 13, 2023 pm 03:33 PM

    MySQL and PostgreSQL: Performance Comparison and Optimization Tips When developing web applications, the database is an indispensable component. When choosing a database management system, MySQL and PostgreSQL are two common choices. They are both open source relational database management systems (RDBMS), but there are some differences in performance and optimization. This article will compare the performance of MySQL and PostgreSQL and provide some optimization tips. Performance comparison comparing two database management

    How to use PostgreSQL database in PHP programming? How to use PostgreSQL database in PHP programming? Jun 12, 2023 am 09:27 AM

    With the development of database technology, database management systems also present a variety of choices. Developers can choose the most suitable database according to their needs and preferences. As an advanced open source relational database system, PostgreSQL is attracting more and more attention and use by developers. So, how to use PostgreSQL database in PHP programming? 1. Install and configure the PostgreSQL database. Before using PostgreSQL, you need to install and configure it. first

    MySQL and PostgreSQL: Data Security and Backup Strategies MySQL and PostgreSQL: Data Security and Backup Strategies Jul 13, 2023 pm 03:31 PM

    MySQL and PostgreSQL: Data Security and Backup Strategies Introduction: In modern society, data has become an indispensable part of business and personal life. For database management systems, data security and backup strategies are crucial, both to protect data from loss or damage and to ensure the reliability and integrity of recovered data. This article will focus on the data security and backup strategies of two mainstream relational database systems, MySQL and PostgreSQL. 1. Data security: (1) User rights

    Using PostgreSQL in Go: The Complete Guide Using PostgreSQL in Go: The Complete Guide Jun 18, 2023 am 09:28 AM

    Go language is a fast and efficient programming language suitable for building web services and back-end applications. PostgreSQL is an open source relational database management system that promises to provide higher reliability, scalability and data security. In this article, we’ll take a deep dive into using PostgreSQL with Go and provide some practical code examples and tips. Installing and setting up PostgreSQL First, we need to install and set up PostgreSQL. Can be found on the official website

    Learn database functions in Go language and implement addition, deletion, modification and query operations of PostgreSQL data Learn database functions in Go language and implement addition, deletion, modification and query operations of PostgreSQL data Jul 31, 2023 pm 12:54 PM

    Learn the database functions in the Go language and implement the addition, deletion, modification, and query operations of PostgreSQL data. In modern software development, the database is an indispensable part. As a powerful programming language, Go language provides a wealth of database operation functions and toolkits, which can easily implement addition, deletion, modification and query operations of the database. This article will introduce how to learn database functions in Go language and use PostgreSQL database for actual operations. Step 1: Install the database driver in Go language for each database

    PHP implements open source PostgreSQL relational database PHP implements open source PostgreSQL relational database Jun 18, 2023 am 08:40 AM

    With the development of the Internet, the amount of data continues to grow, and the need for data management becomes increasingly urgent. Relational database is an important way of data management, among which PostgreSQL is popular for its flexibility, scalability and security. This article introduces how to use the PHP language to implement an open source PostgreSQL relational database. I hope it will be helpful to developers with corresponding needs. Overview PostgreSQL is a powerful relational database system that follows the SQL standard and has many

    MySQL and PostgreSQL: How to optimize database query performance? MySQL and PostgreSQL: How to optimize database query performance? Jul 12, 2023 pm 03:15 PM

    MySQL and PostgreSQL: How to optimize database query performance? Overview: Database query performance is an important consideration when developing applications. Good query performance improves application responsiveness and user experience. This article will introduce some methods to optimize database query performance, focusing on two commonly used databases, MySQL and PostgreSQL. Optimization of database indexes: Database indexes are an important factor in improving query performance. Indexes can speed up data search and reduce query scanning time.

    See all articles