Rechercher dans le manuel MySQL
15.8.3.7 Saving and Restoring the Buffer Pool State
To reduce the warmup period
after restarting the server, InnoDB
saves a
percentage of the most recently used pages for each buffer pool
at server shutdown and restores these pages at server startup.
The percentage of recently used pages that is stored is defined
by the
innodb_buffer_pool_dump_pct
configuration option.
After restarting a busy server, there is typically a warmup period with steadily increasing throughput, as disk pages that were in the buffer pool are brought back into memory (as the same data is queried, updated, and so on). The ability to restore the buffer pool at startup shortens the warmup period by reloading disk pages that were in the buffer pool before the restart rather than waiting for DML operations to access corresponding rows. Also, I/O requests can be performed in large batches, making the overall I/O faster. Page loading happens in the background, and does not delay database startup.
In addition to saving the buffer pool state at shutdown and restoring it at startup, you can save and restore the buffer pool state at any time, while the server is running. For example, you can save the state of the buffer pool after reaching a stable throughput under a steady workload. You could also restore the previous buffer pool state after running reports or maintenance jobs that bring data pages into the buffer pool that are only requited for those operations, or after running some other non-typical workload.
Even though a buffer pool can be many gigabytes in size, the
buffer pool data that InnoDB
saves to disk is
tiny by comparison. Only tablespace IDs and page IDs necessary
to locate the appropriate pages are saved to disk. This
information is derived from the
INNODB_BUFFER_PAGE_LRU
INFORMATION_SCHEMA
table. By default,
tablespace ID and page ID data is saved in a file named
ib_buffer_pool
, which is saved to the
InnoDB
data directory. The file name and
location can be modified using the
innodb_buffer_pool_filename
configuration parameter.
Because data is cached in and aged out of the buffer pool as it is with regular database operations, there is no problem if the disk pages are recently updated, or if a DML operation involves data that has not yet been loaded. The loading mechanism skips requested pages that no longer exist.
The underlying mechanism involves a background thread that is dispatched to perform the dump and load operations.
Disk pages from compressed tables are loaded into the buffer pool in their compressed form. Pages are uncompressed as usual when page contents are accessed during DML operations. Because uncompressing pages is a CPU-intensive process, it is more efficient for concurrency to perform the operation in a connection thread rather than in the single thread that performs the buffer pool restore operation.
Operations related to saving and restoring the buffer pool state are described in the following topics:
Configuring the Dump Percentage for Buffer Pool Pages
Before dumping pages from the buffer pool, you can configure
the percentage of most-recently-used buffer pool pages that
you want to dump by setting the
innodb_buffer_pool_dump_pct
option. If you plan to dump buffer pool pages while the server
is running, you can configure the option dynamically:
If you plan to dump buffer pool pages at server shutdown, set
innodb_buffer_pool_dump_pct
in your configuration file.
[mysqld]
innodb_buffer_pool_dump_pct=40
The
innodb_buffer_pool_dump_pct
default value is 25 (dump 25% of most-recently-used pages).
To save the state of the buffer pool at server shutdown, issue the following statement prior to shutting down the server:
innodb_buffer_pool_dump_at_shutdown
is enabled by default.
To restore the buffer pool state at server startup, specify
the --innodb-buffer-pool-load-at-startup
option when starting the server:
mysqld --innodb-buffer-pool-load-at-startup=ON;
innodb_buffer_pool_load_at_startup
is enabled by default.
To save the state of the buffer pool while MySQL server is running, issue the following statement:
To restore the buffer pool state while MySQL is running, issue the following statement:
To display progress when saving the buffer pool state to disk, issue the following statement:
If the operation has not yet started, “not started” is returned. If the operation is complete, the completion time is printed (e.g. Finished at 110505 12:18:02). If the operation is in progress, status information is provided (e.g. Dumping buffer pool 5/7, page 237/2873).
To display progress when loading the buffer pool, issue the following statement:
If the operation has not yet started, “not started” is returned. If the operation is complete, the completion time is printed (e.g. Finished at 110505 12:23:24). If the operation is in progress, status information is provided (e.g. Loaded 123/22301 pages).
To abort a buffer pool load operation, issue the following statement:
You can monitor buffer pool load progress using Performance Schema.
The following example demonstrates how to enable the
stage/innodb/buffer pool load
stage event
instrument and related consumer tables to monitor buffer pool
load progress.
For information about buffer pool dump and load procedures used in this example, see Section 15.8.3.7, “Saving and Restoring the Buffer Pool State”. For information about Performance Schema stage event instruments and related consumers, see Section 26.12.5, “Performance Schema Stage Event Tables”.
Enable the
stage/innodb/buffer pool load
instrument:Enable the stage event consumer tables, which include
events_stages_current
,events_stages_history
, andevents_stages_history_long
.Dump the current buffer pool state by enabling
innodb_buffer_pool_dump_now
.Check the buffer pool dump status to ensure that the operation has completed.
Load the buffer pool by enabling
innodb_buffer_pool_load_now
:Check the current status of the buffer pool load operation by querying the Performance Schema
events_stages_current
table. TheWORK_COMPLETED
column shows the number of buffer pool pages loaded. TheWORK_ESTIMATED
column provides an estimate of the remaining work, in pages.- FROM performance_schema.events_stages_current;
- +-------------------------------+----------------+----------------+
- | EVENT_NAME | WORK_COMPLETED | WORK_ESTIMATED |
- +-------------------------------+----------------+----------------+
- +-------------------------------+----------------+----------------+
The
events_stages_current
table returns an empty set if the buffer pool load operation has completed. In this case, you can check theevents_stages_history
table to view data for the completed event. For example:- FROM performance_schema.events_stages_history;
- +-------------------------------+----------------+----------------+
- | EVENT_NAME | WORK_COMPLETED | WORK_ESTIMATED |
- +-------------------------------+----------------+----------------+
- +-------------------------------+----------------+----------------+
You can also monitor buffer pool load progress using
Performance Schema when loading the buffer pool at startup
using
innodb_buffer_pool_load_at_startup
.
In this case, the stage/innodb/buffer pool
load
instrument and related consumers must be
enabled at startup. For more information, see
Section 26.3, “Performance Schema Startup Configuration”.
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-innodb-preload-buffer-pool.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.