I have a Drupal site, and I am suffering performance issues. I found How do I convert a database from MyISAM to InnoDB? indicating that performance may improve by switching.
How can I tell if my MySQL database is InnoDB, or MyISAM?
I have a Drupal site, and I am suffering performance issues. I found How do I convert a database from MyISAM to InnoDB? indicating that performance may improve by switching.
How can I tell if my MySQL database is InnoDB, or MyISAM?
You can run a custom query:
SELECT TABLE_NAME, ENGINE
FROM information_schema.TABLES
WHERE TABLE_SCHEMA = 'database_name'
to list all the tables in your database and the engine that's in use for each.
Alternatively you could log into your database using phpMyAdmin and select your database...you'll see the engine in the Type
column in the list of tables.
Personally I'd recommend Navicat for MySQL, it's a very nice MySQL GUI and makes finding out things like this very easy.
SHOW TABLE STATUS
. To get a simple count of how many tables are in each engine type, it's SELECT ENGINE,COUNT(TABLE_NAME) FROM information_schema.TABLES WHERE TABLE_SCHEMA='database_name' GROUP BY ENGINE
.
My best experience was to decide on a per table basis. InnoDB is nice, because it can avoid table locking (no other process can read from a table while one process writes), but it performs terribly with COUNT() which is used often for pager queries.
(Edit: please see Clives comment below)
There are also implications on your MySQL setup, depending which DB you are using. If you have access to the server, mysqltuner should be your first step, to check the configuration:
COUNT
queries, according to this article by the former High Performance Group manager for MySQL though it only really affects a query containing COUNT(*)
without a WHERE
clause.
SELECT COUNT(*) FROM table
can return instantly with that value. InnoDB does not, so it must scan the entire primary key index. That said, while Drupal does a lot of SELECT COUNT(*)
, I can only think of one place in the entire code that does it without a WHERE
clause. Thus, do not use MyISAM out of concern for this particular edgecase. InnoDB with a decent size buffer pool will be faster for all real-world queries.
Just trying things to get a web site faster is like blindely changing cars and hope you get a faster one next time.
First try the low hanging fruits, if it doesn't help, try to find the real bottleneck.
Often it's just a slow DB query which needs an index, or a module doing things in a slow way.
I also discovered big differences between hosters. If you install a fresh drupal out of the box, is the performance ok? If not, it's time to look for an other hoster.
FWIW our almost 20K node Drupal 6.x site was experiencing some performance issues and I did elect to move all the tables to InnoDB. It was easy and the way I handled it was to use mysqldump to dump all content to a sql file, use an editor (sed) to replace all occurrences of MyISAM to InnoDB then reload the database from that file. One of the down sides is that you cannot recover space from an InnoDB database (IIRC) but as long as you keep your duplicate tables in a separate DB you should have no problems. Oh, and we did see a significant performance increase. And because we have four Drupal instances the sheer number of table files was eliminated from the file system (yes, they're contained inside the InnoDB file itself). This is my $.02 worth.
innodb_file_per_table
option.
for tbl in $(mysql -Ne 'show tables' databasename); do mysql -e "ALTER TABLE $tbl ENGINE=InnoDB"; done
. Add appropriate options (-uroot -psomepass
, for example) to the two mysql
s if needed.
Just a heads up. If your on Drupal 6, you can install the DBTuner module; it can easily move your tables from MyISAM to InnoDB. So yes, there's a module for that!