Skip to content

Commit ceae4d7

Browse files
authored
cached table: add links (#18000)
1 parent cfe81c7 commit ceae4d7

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

cached-tables.md

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ This section describes the usage of cached tables by examples.
3333

3434
Suppose that there is a table `users`:
3535

36-
{{< copyable "sql" >}}
37-
3836
```sql
3937
CREATE TABLE users (
4038
id BIGINT,
@@ -45,8 +43,6 @@ CREATE TABLE users (
4543

4644
To set this table to a cached table, use the `ALTER TABLE` statement:
4745

48-
{{< copyable "sql" >}}
49-
5046
```sql
5147
ALTER TABLE users CACHE;
5248
```
@@ -59,8 +55,6 @@ Query OK, 0 rows affected (0.01 sec)
5955

6056
To verify a cached table, use the `SHOW CREATE TABLE` statement. If the table is cached, the returned result contains the `CACHED ON` attribute:
6157

62-
{{< copyable "sql" >}}
63-
6458
```sql
6559
SHOW CREATE TABLE users;
6660
```
@@ -78,9 +72,7 @@ SHOW CREATE TABLE users;
7872
1 row in set (0.00 sec)
7973
```
8074

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

8577
```sql
8678
TRACE SELECT * FROM users;
@@ -106,9 +98,7 @@ TRACE SELECT * FROM users;
10698
12 rows in set (0.01 sec)
10799
```
108100

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

113103
```sql
114104
+----------------------------------------+-----------------+------------+
@@ -127,8 +117,6 @@ After executing `trace` again, the returned result no longer contains the `regio
127117

128118
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`:
129119

130-
{{< copyable "sql" >}}
131-
132120
```sql
133121
+-------------------------+---------+-----------+---------------+--------------------------------+
134122
| id | estRows | task | access object | operator info |
@@ -144,8 +132,6 @@ Note that the `UnionScan` operator is used to read the cached tables, so you can
144132

145133
Cached tables support data writes. For example, you can insert a record into the `users` table:
146134

147-
{{< copyable "sql" >}}
148-
149135
```sql
150136
INSERT INTO users(id, name) VALUES(1001, 'Davis');
151137
```
@@ -154,8 +140,6 @@ INSERT INTO users(id, name) VALUES(1001, 'Davis');
154140
Query OK, 1 row affected (0.00 sec)
155141
```
156142

157-
{{< copyable "sql" >}}
158-
159143
```sql
160144
SELECT * FROM users;
161145
```
@@ -201,8 +185,6 @@ Create Table: CREATE TABLE `table_cache_meta` (
201185
>
202186
> 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.
203187
204-
{{< copyable "sql" >}}
205-
206188
```sql
207189
TRUNCATE TABLE users;
208190
```
@@ -211,8 +193,6 @@ TRUNCATE TABLE users;
211193
ERROR 8242 (HY000): 'Truncate Table' is unsupported on cache tables.
212194
```
213195

214-
{{< copyable "sql" >}}
215-
216196
```sql
217197
mysql> ALTER TABLE users ADD INDEX k_id(id);
218198
```
@@ -223,8 +203,6 @@ ERROR 8242 (HY000): 'Alter Table' is unsupported on cache tables.
223203

224204
To revert a cached table to a normal table, use `ALTER TABLE t NOCACHE`:
225205

226-
{{< copyable "sql" >}}
227-
228206
```sql
229207
ALTER TABLE users NOCACHE;
230208
```

0 commit comments

Comments
 (0)