Rechercher dans le manuel MySQL
13.7.7.2 CACHE INDEX Syntax
The CACHE INDEX
statement assigns
table indexes to a specific key cache. It applies only to
MyISAM
tables, including partitioned
MyISAM
tables. After the indexes have been
assigned, they can be preloaded into the cache if desired with
LOAD INDEX INTO
CACHE
.
The following statement assigns indexes from the tables
t1
, t2
, and
t3
to the key cache named
hot_cache
:
- +---------+--------------------+----------+----------+
- +---------+--------------------+----------+----------+
- +---------+--------------------+----------+----------+
The syntax of CACHE INDEX
enables
you to specify that only particular indexes from a table should
be assigned to the cache. However, the implementation assigns
all the table's indexes to the cache, so there is no reason to
specify anything other than the table name.
The key cache referred to in a CACHE
INDEX
statement can be created by setting its size
with a parameter setting statement or in the server parameter
settings. For example:
Key cache parameters are accessed as members of a structured system variable. See Section 5.1.9.5, “Structured System Variables”.
A key cache must exist before you assign indexes to it, or an error occurs:
By default, table indexes are assigned to the main (default) key cache created at the server startup. When a key cache is destroyed, all indexes assigned to it are reassigned to the default key cache.
Index assignment affects the server globally: If one client assigns an index to a given cache, this cache is used for all queries involving the index, no matter which client issues the queries.
CACHE INDEX
is supported for
partitioned MyISAM
tables. You can assign one
or more indexes for one, several, or all partitions to a given
key cache. For example, you can do the following:
- ENGINE=MyISAM
- PARTITIONS 4;
The previous set of statements performs the following actions:
Creates a partitioned table with 4 partitions; these partitions are automatically named
p0
, ...,p3
; this table has an index namedi
on columnc1
.Creates 2 key caches named
kc_fast
andkc_slow
Assigns the index for partition
p0
to thekc_fast
key cache and the index for partitionsp1
andp3
to thekc_slow
key cache; the index for the remaining partition (p2
) uses the server's default key cache.
If you wish instead to assign the indexes for all partitions in
table pt
to a single key cache named
kc_all
, you can use either of the following
two statements:
The two statements just shown are equivalent, and issuing either
one has exactly the same effect. In other words, if you wish to
assign indexes for all partitions of a partitioned table to the
same key cache, the PARTITION (ALL)
clause is
optional.
When assigning indexes for multiple partitions to a key cache, the partitions need not be contiguous, and you need not list their names in any particular order. Indexes for any partitions not explicitly assigned to a key cache automatically use the server default key cache.
Index preloading is also supported for partitioned
MyISAM
tables. For more information, see
Section 13.7.7.5, “LOAD INDEX INTO CACHE Syntax”.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-cache-index.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.