How Do I Handle Excessive Small Files?
Frequent INSERT, UPDATE, and DELETE operations on Paimon tables generate a large number of small files, which negatively impacts query performance and storage utilization.
Excessive small file are mainly caused by the following issues:
- Queries need to open and read a large number of small files.
- Too many manifest files cause metadata bloat.
Solutions
Paimon provides the following mechanisms to handle excessive small files:
- Synchronous compaction: Automatically triggers compaction during data writing to merge small files into large ones. You can enable this function by setting write.auto-compaction to true.
- Asynchronous compaction: Triggers background asynchronous compaction tasks through Flink or Spark to merge small files without affecting write performance. You can adjust the trigger interval of asynchronous compaction by setting the compaction.optimization-interval parameter.
- Write parameter tuning: Properly sets the target-file-size parameter to control the target file size, and sets the compaction.min.file-num and compaction.max.file-num parameters to control the triggering conditions and merging scope of the compaction.
- Sorted Run merging: For primary key tables, Paimon reduces the file count by merging sorted runs based on the LSM-Tree structure. You can control the number of sorted runs that trigger a merge using the num-sorted-run.compaction-trigger parameter.
Suggestions
- In streaming write scenarios, you are advised to enable asynchronous compaction to avoid the performance penalty associated with synchronous compaction.
- Regularly monitor the number of files and average file size in the table. Trigger compaction promptly if the file count grows abnormally.
- Configure compaction parameters appropriately to avoid resource waste and increased write latency caused by excessive compactions.
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