You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To verify a cached table, use the `SHOW CREATE TABLE` statement. If the table is cached, the returned result contains the `CACHED ON` attribute:
61
57
62
-
{{< copyable "sql" >}}
63
-
64
58
```sql
65
59
SHOW CREATE TABLE users;
66
60
```
@@ -78,9 +72,7 @@ SHOW CREATE TABLE users;
78
72
1 row inset (0.00 sec)
79
73
```
80
74
81
-
After reading data from a cached table, TiDB loads the data in memory. You can use the `trace` statement to check whether the data is loaded into memory. When the cache is not loaded, the returned result contains the `regionRequest.SendReqCtx` attribute, which indicates that TiDB reads data from TiKV.
82
-
83
-
{{< copyable "sql" >}}
75
+
After reading data from a cached table, TiDB loads the data in memory. You can use the [`TRACE`](/sql-statements/sql-statement-trace.md) statement to check whether the data is loaded into memory. When the cache is not loaded, the returned result contains the `regionRequest.SendReqCtx` attribute, which indicates that TiDB reads data from TiKV.
84
76
85
77
```sql
86
78
TRACE SELECT*FROM users;
@@ -106,9 +98,7 @@ TRACE SELECT * FROM users;
106
98
12 rows inset (0.01 sec)
107
99
```
108
100
109
-
After executing `trace` again, the returned result no longer contains the `regionRequest.SendReqCtx` attribute, which indicates that TiDB no longer reads data from TiKV but reads data from the memory instead.
110
-
111
-
{{< copyable "sql" >}}
101
+
After executing [`TRACE`](/sql-statements/sql-statement-trace.md) again, the returned result no longer contains the `regionRequest.SendReqCtx` attribute, which indicates that TiDB no longer reads data from TiKV but reads data from the memory instead.
@@ -127,8 +117,6 @@ After executing `trace` again, the returned result no longer contains the `regio
127
117
128
118
Note that the `UnionScan` operator is used to read the cached tables, so you can see `UnionScan` in the execution plan of the cached tables through `explain`:
> Executing DDL statements on a cached table will fail. Before executing DDL statements on a cached table, you need to remove the cache attribute first and set the cached table back to a normal table.
203
187
204
-
{{< copyable "sql" >}}
205
-
206
188
```sql
207
189
TRUNCATE TABLE users;
208
190
```
@@ -211,8 +193,6 @@ TRUNCATE TABLE users;
211
193
ERROR 8242 (HY000): 'Truncate Table' is unsupported on cache tables.
212
194
```
213
195
214
-
{{< copyable "sql" >}}
215
-
216
196
```sql
217
197
mysql> ALTER TABLE users ADD INDEX k_id(id);
218
198
```
@@ -223,8 +203,6 @@ ERROR 8242 (HY000): 'Alter Table' is unsupported on cache tables.
223
203
224
204
To revert a cached table to a normal table, use `ALTER TABLE t NOCACHE`:
0 commit comments