

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 維護任務的考量和限制
<a name="s3-tables-considerations"></a>

Amazon S3 可提供維護操作，以增強 S3 資料表或資料表儲存貯體的效能。這些選項包括檔案壓縮、快照管理和未參考檔案移除。下列是這些管理選項的限制和考量。

**Topics**
+ [壓縮的考量事項](#s3-tables-compaction-considerations)
+ [快照管理的考量事項](#s3-tables-snapshot-considerations)
+ [移除未參考檔案的考量事項](#s3-tables-unreferenced-file-removal-considerations)
+ [S3 資料表和資料表儲存貯體維護操作限制和相關的 API](#s3-tables-maintenance-limits)

## 壓縮的考量事項
<a name="s3-tables-compaction-considerations"></a>

您應該為壓縮作業考量下列注意事項。如需壓縮的詳細資訊，請參閱[資料表的維護](s3-tables-maintenance.md)。
+ 壓縮支援 Apache Parquet、Avro 和 ORC 檔案類型。
+ 根據預設，壓縮會以 Apache Parquet 格式寫入新檔案。若要改為將檔案壓縮為 Avro 或 ORC 格式，請將 `write.format.default` 資料表屬性設定為 `avro` 或 `orc`。
+ 壓縮不支援資料類型：`Fixed`。
+ 壓縮不支援壓縮類型：`brotli`、`lz4`。
+ 壓縮會在自動排程時發生。如果您想要避免與壓縮相關聯的費用，您可以使用 [PutTableMaintenanceConfiguration](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3Buckets_PutTableMaintenanceConfiguration.html) API 操作，針對資料表手動停用壓縮。

**注意**  
Apache Iceberg 使用開放式並行存取模型，搭配衝突偵測來仲裁寫入交易。透過開放式並行存取，使用者和壓縮交易可能會衝突，導致交易失敗。如果發生衝突，壓縮任務會在失敗後重試。建議讓您的管道也使用重試邏輯，以克服因衝突操作而失敗的交易。

## 快照管理的考量事項
<a name="s3-tables-snapshot-considerations"></a>

您應該為快照管理考量下列注意事項。如需快照管理的詳細資訊，請參閱[資料表的維護](s3-tables-maintenance.md)。
+ 只有在滿足兩個條件時，系統才會保留快照：要保留的快照數量下限和指定的保留期間。
+ 快照管理會從 Apache Iceberg 刪除過期的快照中繼資料，以防止進行過期快照的時間歷程查詢，並選擇性地刪除相關聯的資料檔案。
+ 快照管理不支援您在 `metadata.json` 檔案中或透過 `ALTER TABLE SET TBLPROPERTIES` SQL 命令設定作為 Iceberg 資料表屬性的保留值，包括分支或標籤型保留。在設定分支或標籤型保留政策時，或在 `metadata.json` 檔案上設定的保留政策比透過 `PutTableMaintenanceConfiguration` API 設定之值還長時，系統會停用快照管理。在這些情況下，S3 不會讓快照過期或加以移除，而且您將需要手動刪除快照，或從您的 Iceberg 資料表移除屬性，以避免產生儲存費用。

## 移除未參考檔案的考量事項
<a name="s3-tables-unreferenced-file-removal-considerations"></a>

您應該為移除未參考檔案考量下列注意事項。如需移除未參考檔案的詳細資訊，請參閱[資料表儲存貯體的維護](s3-table-buckets-maintenance.md)。
+ 如果不再由 Iceberg 中繼資料參考之資料和中繼資料檔案的建立時間早於保留期間，則未參考檔案移除會將其刪除。

## S3 資料表和資料表儲存貯體維護操作限制和相關的 API
<a name="s3-tables-maintenance-limits"></a>




| 維護操作 | 屬性 | 是否可在資料表儲存貯體層級進行設定？ | 是否可在資料表層級進行設定？ | 預設值 | 最小值 | 相關的 Iceberg 維護常式 | 控制 S3 Tables API | 
| --- | --- | --- | --- | --- | --- | --- | --- | 
| 壓縮 | targetFileSizeMB | 否 | 是 | 512 MB | 64 MB | [https://iceberg.apache.org/docs/latest/maintenance/#compact-data-files](https://iceberg.apache.org/docs/latest/maintenance/#compact-data-files) | [https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html) | 
| 快照管理 | minimumSnapshots | 否 | 是 | 1 | 1 | [https://iceberg.apache.org/docs/latest/maintenance/#expire-snapshots](https://iceberg.apache.org/docs/latest/maintenance/#expire-snapshots) retainLast | [https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html) | 
| 快照管理 | maximumSnapshotAge | 否 | 是 | 120 小時 | 1 小時 | [https://iceberg.apache.org/docs/latest/maintenance/#expire-snapshots](https://iceberg.apache.org/docs/latest/maintenance/#expire-snapshots) expireOlderThan | [https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableMaintenanceConfiguration.html) | 
| 未參考檔案移除 | unreferencedDays | 是 | 否 | 3 天 | 1 天 | [https://iceberg.apache.org/docs/latest/maintenance/#delete-orphan-files](https://iceberg.apache.org/docs/latest/maintenance/#delete-orphan-files) | [https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableBucketMaintenanceConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableBucketMaintenanceConfiguration.html) | 
| 未參考檔案移除 | nonCurrentDays | 是 | 否 | 10 天 | 1 天 | N/A | [https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableBucketMaintenanceConfiguration.html](https://docs.aws.amazon.com/AmazonS3/latest/API/API_s3tables_PutTableBucketMaintenanceConfiguration.html) | 

**注意**  
S3 Tables 會套用 128 MB 的 parquets row-group-default 大小。