This post contains some technical information that will be very interesting to other developers, but may not be so interesting to those that don’t work with databases.
For those of you that just want the nutshell:
We’ve switched to new database server software because we think the new software will be faster and store the same data while using less disk space (making our storage costs lower).
Now for the detailed explanation:
Back in August, we switched the FeedLounge database from MySQL’s MyISAM tables to InnoDB tables. This solved a number of problems that we were having with the MyISAM tables, but also introduced a number of other issues including slower performance on a number of queries (counting in particular). As we did more and more research into how to solve these problems, we decided that one promising solution would be to switch to a PostgreSQL database instead of a MySQL database altogether.
That is what we were testing this weekend, and the alpha server is now running live with a PostgreSQL database instead of the MySQL database. This is still in “testing” mode - if we run into any serious issues we might switch back (temporarily or permanently) to the MySQL database (which will have data current through last Friday evening).
Some of the reasons we decided to make the switch to PostgreSQL:
- Database size - when we switched from MyISAM tables to InnoDB tables in MySQL, the size of our database grew from ~1GB to 10+GB! When we made the switch this weekend, the MySQL InnoDB database was using 34 GB, and the same data in a PostgreSQL database is only 9.6 GB - this should keep our hardware costs down a bit.
- Load time - The current MySQL setup takes over a day to restore the current database, the load of the data into the PostgreSQL database took just over 4 hours.
I was once given a simplistic summary of the MySQL and PostgreSQL databases:
MySQL was built with speed as the primary feature, PostgreSQL was built with more robust features like triggers, but lacked the speed of MySQL. As both are maturing, they are moving towards the other. MySQL 5 adds triggers and stored procedures, while PostgreSQL is focused on improving performance.
For an application like FeedLounge, the faster counting and smaller row size of PostgreSQL are compelling reasons to use it instead of MySQL with InnoDB tables. Add that it runs in 1/3 the time, using 1/3 the memory (making it essentially 10x faster for us) and that we can start taking advantage of other Postgres features, like data partitioning and partial indices in the near future, and you have the reason we decided to make the switch.
This week should be an interesting one, we’re looking forward to getting feedback from our alpha users on how FeedLounge is performing on the new database.