Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load a MySQL innodb database into memory

I have a MySQL innodb database at 1.9GB, showed by following command.

SELECT table_schema "Data Base Name"
     , sum( data_length + index_length ) / 1 048 576 
       as "Data Base Size in MB"
     , sum( data_free )/ 1 048 576  
       as "Free Space in MB"
FROM information_schema.TABLES
GROUP BY table_schema ; 

+--------------------+----------------------+------------------+
| Data Base Name     | Data Base Size in MB | Free Space in MB |
+--------------------+----------------------+------------------+
| database_name      |        1959.73437500 |   31080.00000000 | 

My questions are:

  1. Does it mean if I set the innodb_buffer_pool_size to 2GB or larger, the whole database can be loaded into memory so much fewer read from disk requests are needed?

  2. What does the free space of 31GB mean?

  3. If the maximum RAM can be allocated to innodb_buffer_pool_size is 1GB, is it possible to specify which tables to loaded into memory while keep others always read from disk?

Thanks in advance.

like image 226
jack Avatar asked Mar 21 '10 05:03

jack


1 Answers

  1. Not exactly. InnoDB buffer pool are used to buffer reads and writes. if most of your access is read, most if it will be cached and fewer disks access will be needed.
  2. could be this bug, it's not documented very well but I think data_free is the available space inside the innodb files (if you write more than this InnoDB will have to enlarge the data file(s)).
  3. no, but InnoDB will cache the data that you access most automatically, so it should have an optimal effect anyway.

consider using memcached as a cache layer to eliminate database access altogether if you need better performance.

like image 180
Omry Yadan Avatar answered Sep 24 '22 01:09

Omry Yadan