UPDATE

Ok folks! Can't wait to share it with you - a solution of the problem which I and probably many of you had experienced. Now it's done!

Symptoms

Drupal runs very slowly on massive database operations like rebuilding it's registry. It executes more then thousand of queries and performs probably hundreds of commits (which are by the way are not displayed in Devel and Devel's query statistics extremely inaccurate).

Optimization

Fixing innodb_flush_log_at_trx_commit

Open mysql console and check the value of innodb_flush_log_at_trx_commit variable:

mysql> show variables like "innodb_flush_log_at_trx_commit";
+--------------------------------+-------+
| Variable_name                  | Value |
+--------------------------------+-------+
| innodb_flush_log_at_trx_commit | 1     |
+--------------------------------+-------+
1 row in set (0.00 sec)

According to MySQL 5.5. documentaion:

When the value is 1 (the default), the log buffer is written out to the log file at each transaction commit and the flush to disk operation is performed on the log file.

When the value is 2, the log buffer is written out to the file at each commit, but the flush to disk operation is not performed on it.

By default this value is set to 1:

The default value of 1 is required for full ACID compliance.

But this is definitely not what you want. You should change its value to 2, which will not trigger flushing to disk on every commit. You can do this in your my.cnf file by adding line to [mysqld] section:

innodb_flush_log_at_trx_commit = 2

After I changed this value to 2 I got speed boost exactly 3 times on my pretty fast desktop. Again, this concerns only COMMITS, and when a user walks your site almost no commits occur. But as developer your DX will speedup dramatically.

Setting proper size if transaction log

to be continued...

Kudos

I want to thank thumbs and threnody from #mysql IRC channel who guided me and helped to locate and fix this problem. Thank you guys!

Blames

I have to blame Devel query logging and counter. It was confusing me all the way, pretending DB takes 10 and 20 times less time then the real workload.

======================================

ORIGINAL POST

Hi all!

Today I've been tuning my InnoDB engine to get the maximum speed when working with a Drupal 7 website. Jumping ahead of myself I can say that I failed with that task and no performance grow I've been witnessed so far.

Certainly, the operation I've been testing is no among the frequent ones - it's about enabling/disabling a module on the /admin/modules page.

At the beginning, the test operation of disabling a module took about 30 seconds.
After 6 hours of fruitless manipulations over my.cnf, I finished with exactly same 30 seconds.

Out of despair, I'd converted my database to MyISAM and was filled with amazement seeing 9 seconds where just been 30!
I repeated it many times with same outcome.
Then I switched back to InnoDB and got 30 seconds back.

I haven't tested the rest of admin/site building tasks yet, and I want to ask the community - have you tried MyISAM instead of InnoDB while development? Indeed using InnoDB on a production website is better and with that I won't argue. But we are developers and spend rather more time on Drupal admin pages, so our primary concern is the speed of the development process.

Look forward to see your comments, firends!

best
Artiom

Comments

dnewkerk’s picture

Do you get the same delay if you enable modules using Drush? I often use Drush for this kind of thing and there's no delay for me (with both MyISAM and InnoDB). However I also have not experienced a long delay when using the modules UI either.

OnkelTem’s picture

Hi, David.

I have plenty of modules installed and enabled so this is the reason why it hits me, I know that. As for the drush - on that operation it is faster on the time of subsequent GET request, when modules page is reloaded on drupal_goto() after form submission, and which is not the case when using CLI of drush.

I think of writing a benchmarking script which executes and measures some often admin operations like: CRUDing fields, visiting some configuration pages, modules page, enabling/disabling modules - with aid of drush of course.

OnkelTem’s picture

So, the 3rd day of living with MyISAM.
Feelings are nice, works like charm.
Editing AJAX-enabled forms became more convenient, without delays.
Server responses faster then before.

stphnlwlsh’s picture

I've been having serious slowness also. I'm not sure what else to do. It doesn't matter if I use drush or the menus. Still slow and page load times are terrible.

Is there any documentation on how to actually go about optimizing MySQL? It seems like everything out there is peicemeal and assumes an expert level of knowledge...

dnewkerk’s picture

This may help: http://www.mysqlperformanceblog.com/2007/11/03/choosing-innodb_buffer_po...
I believe you need to set the InnoDB buffer pool setting to the full size of your database, plus some extra, so long as your computer has enough RAM to do so.

You may also be able to get some tuning help by using this tool: https://tools.percona.com

There are also a few automated tools you can run (not sure if they work on non-Linux systems):
http://mysqltuner.com
http://www.day32.com/MySQL/

OnkelTem’s picture

Thank you very much for this links. Worth to try now, when I got new PC with 16GB of RAM.

OnkelTem’s picture

Fixed! See the first post.

OnkelTem’s picture

Please read the first post update.

OnkelTem’s picture

This is (inline) core patch which changes defaults from InnoDB to MyISAM.
Useful when developing with MyISAM.

--- includes/database/mysql/schema.inc.orig<--->2012-07-25 21:00:32.755911337 +0400
+++ includes/database/mysql/schema.inc<>2012-07-25 20:59:30.791910838 +0400
@@ -80,7 +80,7 @@ class DatabaseSchema_mysql extends Datab
 
     // Provide defaults if needed.
     $table += array(
-      'mysql_engine' => 'InnoDB',
+      'mysql_engine' => 'MyISAM',
       'mysql_character_set' => 'utf8',
     );
 
druper’s picture

I just converted a site DB from InnoDB to MyISAM (due to Media Temple hosting requirements) and was wondering how to make sure all added tables were MyISAM.

Glad you posted this and I bumped into it.

OnkelTem’s picture

Please read the first post update.