tags:

views:

283

answers:

2

in the following link

http://dev.mysql.com/doc/refman/5.1/en/innodb-parameters.html#sysvar_innodb_flush_method

it says:Different values of this variable can have a marked effect on InnoDB performance. For example, on some systems where InnoDB data and log files are located on a SAN, it has been found that setting innodb_flush_method to O_DIRECT can degrade performance of simple SELECT statements by a factor of three.

Why O_DIRECT could slow down the select statement?

+3  A: 

O_DIRECT bypasses the OS's cacheing systems. A SAN may be a very fast storage system, but generally it's going to be somewhere else over a network link and proxied/hidden behind various other layers. By using O_DIRECT, which eliminates local cacheing, you force InnoDB to hit the storage system directly every time.

Marc B
When we use o_direct, we will use almost all the physical memory for mysql to cache the data. So it looks like the mysql document assumes we waste some free memory without allocating them to mysql. If we don't reserve free physical memory, then I thought o_direct won't be slower for select. As if block could be cached inside filesystem, then most likely it can also be cached in mysql buffer if we let mysql use all the free memory.
Daniel
MySQL can and will cache query results, but if any of the queries would require a table scan anyways, then you're off to the disk. With O_DIRECT, there's no disk cache in memory to use, so you're off to the storage medium directly.
Marc B
A: 

You really need to experiment with the flush method on your hardware to see what works best for you. Setting:

innodb_flush_method = O_DIRECT

Improved our performance by 15% on a Dell 2950 server with 15K RPM SAS drives configured in RAID 1 configuration with Dell's PERC caching controller. We're running Ubuntu 9.04 stock kernel and most of the work is mysql using innodb. Your mileage may vary.

Mark Maunder