content_image/740274.jpg content_image/740278.jpg
<img src='content_image/740274.jpg'>

If a MyISAM  table is created with no DATA DIRECTORY  option, the .MYD  file is created in the database directory. By default, if MyISAM  finds an existing .MYD  file in this case, it overwrites it. The same applies to .MYI  files for tables created with no INDEX DIRECTORY  option. To suppress this behavior, set the keep_files_on_create  variable to ON  (1), in which case MyISAM  does not overwrite existing files and returns an error instead. The default value is OFF  (0). 

If a MyISAM  table is created with a DATA DIRECTORY  or INDEX DIRECTORY  option and an existing .MYD  or .MYI  file is found, MyISAM always returns an error. It does not overwrite a file in the specified directory. 

## • key_buffer_size 

<img src='content_image/740278.jpg'>

Index blocks for MyISAM  tables are buffered and are shared by all threads. key_buffer_size  is the size of the buffer used for index blocks. The key buffer is also known as the key cache. 

The maximum permissible setting for key_buffer_size  is 4GB − 1 on 32-bit platforms. Larger values are permitted for 64-bit platforms. The effective maximum size might be less, depending on your available physical RAM and per-process RAM limits imposed by your operating system or hardware platform. The value of this variable indicates the amount of memory requested. Internally, the server allocates as much memory as possible up to this amount, but the actual allocation might be less. 

You can increase the value to get better index handling for all reads and multiple writes; on a system whose primary function is to run MySQL using the MyISAM  storage engine, 25% of the machine’s total memory is an acceptable value for this variable. However, you should be aware that, if you make the value too large (for example, more than 50% of the machine’s total memory), your system might start to page and become extremely slow. This is because MySQL relies on the operating system to perform file system caching for data reads, so you must leave some room for the file system cache. You should also consider the memory requirements of any other storage engines that you may be using in addition to MyISAM . 

For even more speed when writing many rows at the same time, use LOCK TABLES . See Section 8.2.5.1, “Optimizing INSERT Statements” . 

You can check the performance of the key buffer by issuing a SHOW STATUS  statement and examining the Key_read_requests , Key_reads , Key_write_requests , and Key_writes  status variables. (See Section 13.7.7, “SHOW Statements” .) The Key_reads/Key_read_requests  ratio should normally be less than 0.01. The Key_writes/Key_write_requests  ratio is usually near 1 if you are 

