# Cached Table

+ The amount of data in the table is not large
+ Best for Write Once Read Many (`WORM`) tables

![`smart`](HotSubtableCache_aa_002_20220509.png)

------------------------------------------------------------------------
TiDB introduced the cache table feature in v6.0.0. This feature is suitable for hotspot small tables that are frequently accessed and rarely modified. That is, the data of the entire table is loaded into the memory of the TiDB server, and then the table data can be obtained directly from the memory, which avoiding fetching table data from TiKV nodes, thus improving the read performance.

We can use the following method to cache a table:

```
CREATE TABLE users (
    id BIGINT,
    name VARCHAR(100),
    PRIMARY KEY(id)
);

ALTER TABLE users CACHE;
```

The cached table feature is suitable for tables with the following characteristics:
- The amount of data in the table is small
- (Almost) read-only table
- The table is accessed frequently and better read performance is expected

Currently, TiDB has a limit of 64 MB per cache table. `ALTER TABLE t CACHE` will fail if the table is larger than 64 MB.
