Home Database Mysql Tutorial 选择 PosgreSQL 的十个理由,和几个 MySQL 胜出的特性

选择 PosgreSQL 的十个理由,和几个 MySQL 胜出的特性

Jun 07, 2016 pm 03:13 PM
mysql several win choose

一、 PostgreSQL 的稳定性极强,的确,MySQL 有多种引擎,也确实 Innodb 等引擎在崩溃、断电之类的灾难场景下抗打击能力有了长足进步,但是,很多 MySQL 用户都遇到过Server级的数据库丢失的场景——mysql系统库是MyISAM的……PG数据库15分钟被闪断四次的前D

一、 PostgreSQL 的稳定性极强,的确,MySQL 有多种引擎,也确实 Innodb 等引擎在崩溃、断电之类的灾难场景下抗打击能力有了长足进步,但是,很多 MySQL 用户都遇到过Server级的数据库丢失的场景——mysql系统库是MyISAM的……PG数据库15分钟被闪断四次的前DBA毫无压力的含笑而过。


二、任何系统都有它的性能极限,在高并发读写,负载逼近极限下,PG的性能指标仍可以维持双曲线甚至对数曲线,而 MySQL 明显出现一个波峰后下滑。这些曲线在第三方的测试数据中频繁出现,有兴趣的朋友可以 Google 或自己构建一个测试。


三、在欧美 PG 远没有在中国这么非主流,很多优秀的团队都在用, 主流的开发语言几乎都有 PG 的成熟开发接口,这一点不必有顾虑。像 Python 的 dbapi ,还支持 PG 的异步读写,著名的 SQLAlchemy 对PG的一些特有功能也有支持。


四、PG 多年来在 GIS 领域处于优势地位,因为它有丰富的几何类型,实际上不止几何类型,PG有大量字典、数组、bitmap 等数据类型,通过 SQLAlchemy 这样的工具,可以大大简化开发人员的工作。

五、PG 的“无锁定”特性非常突出,很多 MySQL 需要锁表(也许是在你没有发现的情况下)的操作,PG都可以平滑处理,甚至包括 vacuum 这样的整理数据空间的操作。这就是PG高并发下优异性能的奥秘。


六、PG 的可以使用函数和条件索引,这使得PG数据库的调优非常灵活,而这些功能是经过几十年发展和应用考验的,绝非某个一度反复宣称自己不支持的技术全都是“复杂而无用的”,直到自己支持这些技术为止的数据库产品可以相比的。


七、PG 对于数据分析师有难以抗拒的魅力,它有极其强悍的 SQL 编程能力(9.x 图灵完备,支持递归!),有非常丰富的统计函数和统计语法支持,例如 http://t.cn/zOqiVYc 这里的 window 语法。PG 还可以方便的使用 Python、Perl 甚至任何你喜欢的编程语言写函数。


八、PG 的有多种集群架构可以选择,plproxy 可以支持语句级的镜像或分片,slony 可以进行字段级的同步设置,standby 可以构建WAL文件级或流式的读写分离集群,同步频率和集群策略调整方便,操作非常简单。有年在腾讯广州举办的 barcamp ,我现场演示,一次成功。


九、一般关系型数据库的字符串有限定长度8k左右,无限长 TEXT 类型的功能受限,只能作为外部大数据访问。而 PG 的 TEXT 类型可以直接访问,SQL语法内置正则表达式,可以索引,还可以全文检索,或使用xml xpath。用PG的话,文档数据库都可以省了。


十、PG是BSD类的授权协议,如果你真的对它有足够的兴趣和动力,可以尽情的阅读代码,修改定制。这是出自伯克利校园,历经数十年锤炼的优秀代码,是巨大的宝藏。


==================================================================

最后说一下我感觉 PG 不如 MySQL 的地方。


第一,MySQL有一些实用的运维支持,如 slow-query.log ,这个pg肯定可以定制出来,但是如果可以配置使用就更好了。


第二是mysql的innodb引擎,可以充分优化利用系统所有内存,超大内存下PG对内存使用的不那么充分,


第三是mysql有内存表,这是个被低估的功能。


第四点,MySQL现在允许跳过SQL,在socket上直接调用API,这是个勇敢的尝试,虽然整个社区用的还不多,但是遇到极端场景,需要榨干性能的团队,值得尝试。 

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 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months 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)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

How to use MySQL backup and restore in PHP? How to use MySQL backup and restore in PHP? Jun 03, 2024 pm 12:19 PM

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to optimize MySQL query performance in PHP? How to optimize MySQL query performance in PHP? Jun 03, 2024 pm 08:11 PM

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

How to insert data into a MySQL table using PHP? How to insert data into a MySQL table using PHP? Jun 02, 2024 pm 02:26 PM

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values ​​to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

How to create a MySQL table using PHP? How to create a MySQL table using PHP? Jun 04, 2024 pm 01:57 PM

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to use MySQL stored procedures in PHP? How to use MySQL stored procedures in PHP? Jun 02, 2024 pm 02:13 PM

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

How to fix mysql_native_password not loaded errors on MySQL 8.4 How to fix mysql_native_password not loaded errors on MySQL 8.4 Dec 09, 2024 am 11:42 AM

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

The difference between oracle database and mysql The difference between oracle database and mysql May 10, 2024 am 01:54 AM

Oracle database and MySQL are both databases based on the relational model, but Oracle is superior in terms of compatibility, scalability, data types and security; while MySQL focuses on speed and flexibility and is more suitable for small to medium-sized data sets. . ① Oracle provides a wide range of data types, ② provides advanced security features, ③ is suitable for enterprise-level applications; ① MySQL supports NoSQL data types, ② has fewer security measures, and ③ is suitable for small to medium-sized applications.

See all articles