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
Copy file name to clipboardExpand all lines: docs/en/guides/57-data-management/04-data-recycle.md
+13-25Lines changed: 13 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,37 +19,25 @@ Before DELETE: After DELETE: After VACUUM:
19
19
Storage not freed Storage freed
20
20
```
21
21
22
-
## Types of Data to Clean
22
+
## VACUUM Commands and Cleanup Scope
23
23
24
-
Databend provides specific commands to clean different types of data. The following table summarizes the data types and their corresponding cleanup commands:
24
+
Databend provides three VACUUM commands to clean different types of data. **Understanding what each command cleans is crucial** - some commands only clean storage data, while others clean both storage and metadata.
25
25
26
-
| Data Type | Description | Cleanup Command |
27
-
|-----------|-------------|-----------------|
28
-
|**Dropped Table Data**| Data files from tables that have been dropped using the DROP TABLE command |`VACUUM DROP TABLE`|
29
-
|**Table History Data**| Historical versions of tables, including snapshots created through UPDATE, DELETE, and other operations |`VACUUM TABLE`|
30
-
|**Orphan Files**| Snapshots, segments, and blocks that are no longer associated with any table |`VACUUM TABLE`|
31
-
|**Spill Temporary Files**| Temporary files created when memory usage exceeds available limits during query execution (for joins, aggregates, sorts, etc.) |`VACUUM TEMPORARY FILES`|
32
-
33
-
> **Note**: Spill temporary files are typically cleaned automatically by Databend. Manual cleanup is only needed when Databend crashes or shuts down unexpectedly during query execution.
26
+
| Command | Target Data | S3 Storage | Meta Service | Details |
|**VACUUM DROP TABLE**| Dropped tables after `DROP TABLE`| ✅ **Removes**: All data files, segments, blocks, indexes, statistics | ✅ **Removes**: Table schema, permissions, metadata records |**Complete purge** - table cannot be recovered |
29
+
|**VACUUM TABLE**| Table history & orphan files | ✅ **Removes**: Historical snapshots, orphan segments/blocks, old indexes/stats | ❌ **Preserves**: Table structure and current metadata |**Storage-only** - table remains active |
30
+
|**VACUUM TEMPORARY FILES**| Spill files from queries (joins, aggregates, sorts) | ✅ **Removes**: Temporary spill files from crashed/interrupted queries | ❌ **No metadata**: Temp files have no associated metadata |**Storage-only** - rarely needed, auto-cleaned normally |
34
31
32
+
> **Critical**: Only `VACUUM DROP TABLE` removes metadata from the meta service. The other commands only clean storage files.
35
33
36
34
## Using VACUUM Commands
37
35
38
-
The VACUUM command family is the primary method for cleaning data in Databend ([Enterprise Edition Feature](/guides/products/dee/enterprise-features)). Different VACUUM subcommands are used depending on the type of data you need to clean.
The VACUUM command family is the primary method for cleaning data in Databend ([Enterprise Edition Feature](/guides/products/dee/enterprise-features)).
49
37
50
38
### VACUUM DROP TABLE
51
39
52
-
This command permanently deletes data files of dropped tables, freeing up storage space.
40
+
Permanently removes dropped tables from both storage and metadata.
53
41
54
42
```sql
55
43
VACUUM DROP TABLE [FROM<database_name>] [DRY RUN [SUMMARY]] [LIMIT<file_count>];
@@ -78,7 +66,7 @@ VACUUM DROP TABLE LIMIT 1000;
78
66
79
67
### VACUUM TABLE
80
68
81
-
This command removes historical data for a specified table, clearing old versions and freeing storage.
69
+
Removes historical data and orphan files for active tables (storage-only cleanup).
82
70
83
71
```sql
84
72
VACUUM TABLE <table_name> [DRY RUN [SUMMARY]];
@@ -102,13 +90,13 @@ VACUUM TABLE my_table;
102
90
103
91
### VACUUM TEMPORARY FILES
104
92
105
-
This command clears temporary spilled files used for joins, aggregates, and sorts, freeing up storage space.
93
+
Removes temporary spill files created during query execution.
106
94
107
95
```sql
108
96
VACUUM TEMPORARY FILES;
109
97
```
110
98
111
-
**Note:** While this command is provided as a manual method for cleaning up temporary files, it's rarely needed during normal operation since Databend automatically handles cleanup in most cases.
99
+
> **Note**: Rarely needed during normal operation since Databend automatically handles cleanup. Manual cleanup is typically only required when Databend crashes during query execution.
0 commit comments