Professional Documents
Culture Documents
10 Reasons Why Mysql Users Should Move To Postgresql - en
10 Reasons Why Mysql Users Should Move To Postgresql - en
10 Reasons Why Mysql Users Should Move To Postgresql - en
15 June 2011
Copyright 2011, 2ndQuadrant Limited. All rights reserved. This document is provided for information purposes only and the contents hereof are subject to change without notice. This document is not warranted to be error-free, nor subject to any other warranties or conditions, whether expressed orally or implied in law, including implied warranties and conditions of merchantability or fitness for a particular purpose. We specifically disclaim any liability with respect to this document and no contractual obligations are formed either directly or indirectly by this document. This document may not be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose, without our prior written permission. The PostgreSQL elephant logo "Slonik" is a registered trademark of the PostgreSQL Global Development Group. MySQL is a registered trademark of Oracle Corporation and/or its affiliates.
Table of Contents
Introduction ................................................................................................................................ Comparing MySQL and PostgreSQL at a glance ............................................................................... Reason 1: Enterprise class query planner ........................................................................................ Reason 2: Crash safety, reliability and the Write-ahead log ................................................................. Reason 3: Streaming replication ..................................................................................................... Reason 4: Excellent third-party/satellite tools .................................................................................... Reason 5: Advanced Features ....................................................................................................... Reason 6: Quality and data-integrity first .......................................................................................... Reason 7: Licensing .................................................................................................................... Reason 8: Strong community ......................................................................................................... Reason 9: Procedural languages .................................................................................................... Reason 10: SQL compliance and integration .................................................................................... Advanced, ISO conforming SQL dialect ................................................................................... Support for popular ORMs .................................................................................................... About 2ndQuadrant ...................................................................................................................... Business and Contact Information .................................................................................................. 3 3 3 4 4 5 5 6 6 6 7 7 7 8 8 8
Introduction
Over the last decade, the two main open-source database solutions were MySQL and PostgreSQL. Among ICT professionals, there is a traditional perception that MySQL is faster and easier to use than PostgreSQL. On the other hand, PostgreSQL has always been acknowledged to be more feature-rich and robust than MySQL. Over the years, both products have probably learnt from each other, and both have certainly improved considerably. PostgreSQL, with 5 major releases in the last five years, has focused on improving performance, high availability and replication as well as making life easier for DBAs and system administrators. The intended audience of this whitepaper is MySQL users and developers who are interested in PostgreSQL. These 10 reasons cover both the product (the PostgreSQL object-relational DBMS) and the open source project (licensing, community, related tools, the PostgreSQL ecosystem, etc.).
PostgreSQL 9 TPL
b
Free
Row & d Statement LDAP, GSSAPI, SSPI, SSL Certificate, Radius, etc.
e
ACID transactions Online Hot Backup Master-Slave Replication Partitioning Point-In-Time Recovery Administration GUI Monitoring tools Bug fixes, security and maintenance releases Professional 24x7 support
a b c
GNU General Public License: http://www.gnu.org/licenses/gpl.html The PostgreSQL License is a highly permissive BSD-style license: http://www.postgresql.org/about/licence PostgreSQL 9.1 will support triggers on views PostgreSQL 9.1 will support synchronous replication Integration with standard monitoring and alerting tools such as Cacti, Munin and Nagios
MySQL license costs are per 1-4 socket server per year. Pricing on 5+ socket servers requires contacting Oracle Sales Team
d e f
PostgreSQL uses cost-based query optimization methods in order to get good performance for many different types of joins. Query costs are assessed based on planner statistics collected when tables are analyzed combined with adjustable planner cost constants. Advanced features such as the Genetic Query Optimizer allow optimizing even very complicated joins efficiently. MySQLs query optimizer estimates cost by heuristically calculating the number of disk blocks that will most likely need to be read. Because the query optimizer is implemented in the server, not the storage engines, not all the salient information is available to the optimizer. When the optimizer chooses badly, there are only a few tunables for Controlling Query Optimizer Performance. Developers must do things like explicitly provide index hints to make sure joins are executed correctly. To make this task smoother, MySQL provides a Query Profiler that is easier to work with than typical EXPLAIN data. Finding order in execution provides several comparisons of how the two databases handle queries differently. Because of its more robust automatic optimization, PostgreSQL usually does a better job of handling complicated joins than MySQL. Slow queries on PostgreSQL can easily have their explains automatically logged using the auto_explain 1 module . This approach is useful for DBAs who like to pro-actively tune slow-performing queries.
2ndQuadrant has developed repmgr , an open-source tool for managing PostgreSQL replication at a very high level. Features include the ability to: Create new standbys using PostgreSQL Streaming Replication; Analyse replication lag that impacts both high availability and Hot Standby queries; Perform maintenance tasks required to handle failover when a node is removed from the standby cluster, either intentionally or via failure.
Another advanced feature is exclusion constraints. Exclusion constraints are described as a generalisation of unique constraints across all operators. This feature is often used to solve the double-booking problem (ensure that each room, each of which can be in use for some period of time, isnt double booked), without race conditions, and without heavy, explicit table-level locks. PostgreSQL has been the subject of numerous academic papers and research projects, and is considered a good basis for cutting-edge database research. For example, it will soon have the first production implementation of Serializable snapshot isolation (SSI), which is based on a 2008 academic paper by Cahill, et al, which itself won a best paper award from ACM SIGMOD.
Reason 7: Licensing
While 2ndQuadrant employees are very well represented among the developers of PostgreSQL, 2ndQuadrant do not dominate or otherwise control PostgreSQLs development, nor does any other commercial entity. Copyright of the source code is implicitly assigned to the PostgreSQL Global Development Group, a unincorporated loose association of PostgreSQL developers. Given the extremely liberal terms of the BSD-style PostgreSQL licence, it would not make any practical difference if a commercial entity were assigned the copyright. In contrast, Oracle owns the source code of MySQL , and vigorously pursues violators of its licensing terms. MySQL AB and its successors have a long history of ensuring that all available database APIs were GPL licensed, to force proprietary application developers to either make their client applications GPL open source, or to purchase commercial licences (when an application links to a library, it is generally considered to be a derivative work; when it connects over a network, it is generally not).
MySQL suffers from a proliferation of storage engines, including MyISAM, Percona, OurDelta, InnoDB and Falcon (discontinued after Oracle acquisition). The PostgreSQL community revolves around community PostgreSQL. While there is a small number of proprietary forks that serve niche markets, such as EMCs leading data warehousing solution Greenplum, there is a singular focus on improving PostgreSQL as a general database that performs well with varied types of work. PostgreSQL treats documentation as part of the project proper in other words, all patches written must have accompanying documentation, and the documentation is stored as SGML in the same source repository as the source code to the server itself. Errors in the documentation are considered to be bugs, and are fixed with the same expediency as any other sort of bug. The documentation is extensive, organised, and of high quality. Finally, the PostgreSQL community is extended across the world; It has representatives and volunteers in many countries of all continents that have embraced the open-source spirit.
About 2ndQuadrant
2ndQuadrant are the leading experts in PostgreSQL administration and performance tuning, specialising in critical operational databases for customers worldwide. We provide hands-on services covering the following areas: Operational DBA Operational Support Development/Consulting Custom PostgreSQL development
2ndQuadrants customers include BBC, Comodo, Enova Financial, Ericsson, F-Secure, McAfee, Skype and many others. 2ndQuadrant has more than 20 staff supporting customers in more than 16 countries from offices in US, UK, France, Italy and Germany, with staff located worldwide. 2ndQuadrants headquarters are in the UK. 2ndQuadrants differentiator is our ability to deploy top-level skills when and where they are needed. Our strategy is to employ leading solution experts people who have contributed directly to the core technologies around PostgreSQL and at the same time have extensive experience on real world solutions. 2ndQuadrant are also a close partner of EMC, having worked with Greenplum closely since 2005, as a result of our skills and experience with Data Warehousing database systems. 2ndQuadrant are the only company worldwide able to offer both PostgreSQL and Greenplum services, with a team of 6 staff experienced with Greenplum technology.