PostgreSQL or MySQL: Which is faster?

There isn't always a clear-cut answer in the race between dueling databases, PostgreSQL and MySQL, says an expert. Find out his thoughts and how the two compare.

What makes an enterprise-class database? Redundancy and failover capabilities are just two important features that MySQL expert Scott Noyes names. Noyes also tackles the issue of who's faster: PostgreSQL or MySQL. Along the way, he gives some advice for users working with Sybase and MySQL.

More on MySQL:
Ask Scott a Linux database question

Five reasons why you should never use PostgreSQL -- ever

Which is faster: PostgreSQL or MySQL?

Scott Noyes: It's easy to find benchmarks that favor one database over another, depending on the hardware, the configuration and the test. One database might do better on a single-core machine with little memory, while another can take better advantage of scaling to multiple core processors. One might lead on reads while another leads on writes.

What are considered enterprise-class features and, of these, what qualities does MySQL have to offer?

Noyes: Typical enterprise-class features include ACID-compliance, redundancy, automatic failover and very large datasets. MySQL offers all of those features, along with support to help your company configure your servers for optimal performance. See MySQL's offerings for details.

How different is Perl or PHP functionality in MySQL vs. PostgreSQL?

Noyes: This question could mean one of two things. It might be, "How do I write Perl or PHP code that uses a MySQL or PostgreSQL database?" Or, it might be, "Is it possible to write functions and procedures in MySQL and PostgreSQL using Perl or PHP?" For the former, there are a few choices. PHP offers extensions specific to MySQL and to PostgreSQL, so you might write code using mysql_query or pg_query. You can also use PDO or ODBC to connect in a more or less database agnostic manner.

For the latter, PostgreSQL offers PL/Perl and PL/php, which allow you to write procedures in Perl and PHP. PL/Perl is currently more stable than PL/php.

With the aid of some user-defined functions and a thread-safe compilation, it is possible to write functions for MySQL using Perl and PHP. See http://www.linuxjournal.com/article/6841 and http://www.sklar.com/page/article/myphp for details. It is possible that future versions of MySQL will allow a more "plug and play" approach to coding procedures in other languages.

How can PostgreSQL users connect to ASP?

Noyes: You can connect ASP to PostgreSQL using ADO, ODBC or the .Net interface.

Can tables be imported to Sybase from MySQL?

Noyes: If you stick with SQL standard data types, it should be easy to export the database to SQL statements using mysqldump and executing those in Sybase. There might be some minor modifications necessary, especially if Sybase handles indexes or NULL values a little differently. Advanced features like triggers, sequences, stored procedures and configuration settings are unlikely to port directly between databases.

Have a question or comment about the tip? Email us. And don't forget to visit our new blog, the Enterprise Linux Log.

Dig Deeper on Linux servers