How Do I Maintain Tables?
Routine maintenance of Paimon tables is crucial for ensuring query performance and storage utilization. Key maintenance tasks include clearing expired snapshots, merging small files, and rewriting manifest files.
Clearing Expired Snapshots
Each batch written to the table generates a new snapshot. Paimon tracks these snapshots in the table metadata until they expire. Frequent commits may lead to snapshot stacking, so routine maintenance is required, especially for streaming tables.
- snapshot.num-retained.max: Controls the maximum number of snapshots to retain. The default value is 10.
- snapshot.num-retained.min: Controls the minimum number of snapshots to retain. The default value is 3.
- snapshot.time-retained: Controls the time range for retaining snapshots. Snapshots older than this range will be automatically deleted.
Merging Small Files
Streaming writes often result in small data batches, leading to a large number of small files. Compaction merges small files into larger ones, reducing the number of manifest files and optimizing query efficiency.
- Synchronous compaction: Manually triggered using the ALTER TABLE statement or automatically triggered during data writes.
- Asynchronous compaction: Triggered by submitting asynchronous compaction tasks via Flink or Spark to merge small files in the background.
Rewriting Manifest Files
Paimon continuously generates new manifest files during the write process. To optimize query planning performance, you can merge multiple small manifest files into large ones.
- Perform the compaction to indirectly trigger manifest file merging.
- Regularly perform table maintenance to keep the number of manifest files within a reasonable range.
Suggestions
- Suggestion 1: Regularly delete expired snapshots to prevent metadata bloat caused by an excessive number of snapshots.
- Suggestion 2: Periodically perform the compaction to merge small files and optimize query performance.
- Suggestion 3: Create tags for critical data versions to facilitate quick rollback to a specific version.
- Suggestion 4: Monitor the number of files and storage size of tables to detect and resolve storage issues promptly.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot