This Howtos posted under: Articles, Database, MySQL | Total Visitors Till Now: 425

How to choose between MySQL or PostgreSQL – A Comparison

MySQL vs PostgreSQL is a decision many must make when approaching open-source relational databases management systems. Both are time-proven solutions that compete strongly with propriety database software. MySQL has long been assumed to be the faster but featureless of the two database systems, while PostgreSQL was assumed to be a more densely featured database system often described as an open-source version of Oracle. MySQL has been popular among various software projects because of its speed and ease of use, while PostgreSQL has had a close following from developers who come from an Oracle or SQL Server background.

These assumptions, however, are mostly outdated and incorrect. MySQL has come a long way in adding advanced functionality while PostgreSQL dramatically improved its speed within the last major releases. Many, however, are unaware of the convergence and still hold on to stereotypes based on MySQL 4.1 and PostgreSQL 7.4.

Table A is a side-by-side comparison of some of the more frequently used features of MySQL and PostgreSQL.

Table A is not an exhaustive list of features, data types, or performance issues relating to these two database systems—it just gives a view of what each has to offer. From the table we see that PostgreSQL offers overall features for traditional database applications, while MySQL focuses on faster performance for Web-based applications. Open source development will bring more features to subsequent releases of both databases.

Table A

POSTGRESQL MYSQL
ANSI SQL compliance Closer to ANSI SQL standard Follows some of the ANSI SQL standards
Performance Slower Faster
Sub-selects Yes No
Transactions Yes Yes, however InnoDB table type must be used
Database replication Yes Yes
Foreign key support Yes No
Views Yes No
Stored procedures Yes No
Triggers Yes No
Unions Yes No
Full joins Yes No
Constraints Yes No
Windows support Yes Yes
Vacuum (cleanup) Yes No
ODBC Yes Yes
JDBC Yes Yes
Different table types No Yes

MySQL and PostgreSQL comparison

When to use MySQL
Why would you use MySQL over PostgreSQL? First, we need to consider the needs of the applications in terms of database requirements. If I want to create a Web application and performance is an issue, MySQL will be my choice because it’s fast and designed to work well with Web-based servers. However, if I want to create another application that demands transactions and foreign key references, PostgreSQL is the choice.

As an open source developer, I work with both databases on a regular basis, and I typically use all the features of a given database in the design and development process. It wouldn’t suffice for me to use PostgreSQL for a database-driven Web site when my application requires performance.

Even though MySQL is not fully compliant with the ANSI SQL standard, I should mention that, while PostgreSQL is closer to the ANSI SQL standard, MySQL is closer to the ODBC standard.

Let me suggest some reasons for using MySQL over PostgreSQL:

  • MySQL is relatively faster than PostgreSQL.
  • Database design will be simpler.
  • You can create a basic Web-driven Web site.
  • MySQL’s replication has been thoroughly tested.
  • There’s no need for cleanups in MySQL (Vacuum).

When to use PostgreSQL

Not many Web developers use PostgreSQL because they feel that the additional features degrade performance.  However, PostgreSQL offers many advantages over MySQL.

For example, some of the features I use are foreign key references, triggers, and views. They allow me to hide the complexity of the database from the application, thus avoiding the creation of complicated SQL commands. I know many developers who prefer the rich functionality of PostgreSQL’s SQL commands. One of the most notable differences between MySQL and PostgreSQL is the fact that you can’t do nested subqueries of subselects in MySQL. PostgreSQL follows many of the SQL ANSI standards, thus allowing the creation of complex SQL commands.

Let me suggest some reasons for using PostgreSQL over MySQL:

  • Complex database design
  • Moving away from Oracle, Sybase, or MSSQL
  • Complex rule sets (i.e., business rules)
  • Use of procedural languages on the server
  • Transactions
  • Use of stored procedures
  • Use of geographical data
  • R-Trees (i.e., used on indexes)

MySQL is widely popular among various open-source web development packages. The MyISAM engine often is the only database engine included in webhosting providers. Many web developers use MySQL. Thus, MySQL became widely popular in web development, and MySQL calls itself “The world’s most popular open source database,” a claim that may be spurious given the broad deployment of other open source DBMSes such as SQLite.

Thus, MySQL is stereotyped as “easier” to use than PostgreSQL because of its popularity.

Coolsearchinfo - A free Social Bookmarking Site

Liked this article? To continue getting our latest free Howtos and Tutorials,
you can also grab the RSS feed or Subscribe to Techgurulive by Email

Not Getting



Related posts
  • OpenSource key application development tools from Google
    Google has decided to release as open source several of its key application development tools, hoping that they will prove useful for external programmers to build faster Web applications. Google...
  • How MySQL Uses Indexes
    Indexes are used to find rows with a specific value of one column fast. Without an index MySQL has to start with the first record and then read through the...