Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code DEF204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher dans le manuel MySQL

13.7.7.2 CACHE INDEX Syntax

  1. CACHE INDEX {
  2.       tbl_index_list [, tbl_index_list] ...
  3.     | tbl_name PARTITION (partition_list)
  4.   }
  5.   IN key_cache_name
  6.  
  7. tbl_index_list:
  8.   tbl_name [{INDEX|KEY} (index_name[, index_name] ...)]
  9.  
  10. partition_list: {
  11.     partition_name[, partition_name] ...
  12.   | ALL
  13. }

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:

  1. mysql> CACHE INDEX t1, t2, t3 IN hot_cache;
  2. +---------+--------------------+----------+----------+
  3. | Table   | Op                 | Msg_type | Msg_text |
  4. +---------+--------------------+----------+----------+
  5. | test.t1 | assign_to_keycache | status   | OK       |
  6. | test.t2 | assign_to_keycache | status   | OK       |
  7. | test.t3 | assign_to_keycache | status   | OK       |
  8. +---------+--------------------+----------+----------+

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:

  1. SET GLOBAL keycache1.key_buffer_size=128*1024;

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:

  1. mysql> CACHE INDEX t1 IN non_existent_cache;
  2. ERROR 1284 (HY000): Unknown key cache 'non_existent_cache'

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:

  1. CREATE TABLE pt (c1 INT, c2 VARCHAR(50), INDEX i(c1))
  2.     ENGINE=MyISAM
  3.     PARTITION BY HASH(c1)
  4.     PARTITIONS 4;
  5.  
  6. SET GLOBAL kc_fast.key_buffer_size = 128 * 1024;
  7. SET GLOBAL kc_slow.key_buffer_size = 128 * 1024;
  8.  
  9. CACHE INDEX pt PARTITION (p0) IN kc_fast;
  10. CACHE INDEX pt PARTITION (p1, p3) IN kc_slow;

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 named i on column c1.

  • Creates 2 key caches named kc_fast and kc_slow

  • Assigns the index for partition p0 to the kc_fast key cache and the index for partitions p1 and p3 to the kc_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:

  1. CACHE INDEX pt PARTITION (ALL) IN kc_all;
  2.  
  3. CACHE INDEX pt IN kc_all;

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”.


Zoek in de MySQL-handleiding

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-cache-index.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

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

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.

Inhoudsopgave Haut