跳转到主内容
跳转到主内容

system.part_log

在 ClickHouse Cloud 中进行查询

该系统表中的数据保存在 ClickHouse Cloud 中每个节点的本地。因此,如需获得所有数据的完整视图,需要使用 clusterAllReplicas 函数。更多详情请参阅此处

描述

只有在指定了 part_log 服务器设置时,才会创建 system.part_log 表。

此表包含关于 MergeTree 系列表中数据分片发生的事件的信息,例如数据的添加或合并。

system.part_log 表包含以下列:

  • hostname (LowCardinality(String)) — 执行该查询的服务器主机名。
  • query_id (String) — 用于创建此数据分区片段的 INSERT 查询的标识符。
  • event_type (Enum8('NewPart' = 1, 'MergeParts' = 2, 'DownloadPart' = 3, 'RemovePart' = 4, 'MutatePart' = 5, 'MovePart' = 6, 'MergePartsStart' = 7, 'MutatePartStart' = 8)) — 与数据分区片段相关的事件类型。可以取以下值之一:NewPart — 插入新的数据分区片段,MergePartsStart — 数据分区片段合并已开始,MergeParts — 数据分区片段合并已完成,DownloadPart — 下载数据分区片段,RemovePart — 使用 DETACH PARTITION 删除或分离数据分区片段。MutatePartStart — 数据分区片段变更已开始,MutatePart — 数据分区片段变更已完成,MovePart — 将数据分区片段从一个磁盘移动到另一个磁盘。
  • merge_reason (Enum8('NotAMerge' = 1, 'RegularMerge' = 2, 'TTLDeleteMerge' = 3, 'TTLRecompressMerge' = 4, 'TTLDropMerge' = 5)) — 类型为 MERGE_PARTS 的事件发生原因。可以具有以下值之一:NotAMerge — 当前事件的类型不是 MERGE_PARTS,RegularMerge — 某个常规合并,TTLDeleteMerge、TTLDropMerge — 清理过期数据。TTLRecompressMerge — 对数据分区片段进行重新压缩。
  • merge_algorithm (Enum8('Undecided' = 0, 'Vertical' = 1, 'Horizontal' = 2)) — 类型为 MERGE_PARTS 的事件所使用的合并算法。可取以下值之一:Undecided、Horizontal、Vertical
  • event_date (Date) — 事件日期。
  • event_time (DateTime) — 事件时间。
  • event_time_microseconds (DateTime64(6)) — 精确到微秒的事件时间。
  • duration_ms (UInt64) — 此操作的耗时。
  • database (String) — 数据分区片段所在的数据库名称。
  • table (String) — 数据分区片段所在的表名称。
  • table_uuid (UUID) — 该数据分区片段所属的表的 UUID。
  • part_name (String) — 数据分区片段名称。
  • partition_id (String) — 数据分区片段插入到的分区 ID。如果采用 tuple() 进行分区,则该列的值为 all
  • partition (String) — 分区名称。
  • part_type (String) — part 的类型。可选值:Wide 和 Compact。
  • part_storage_type (String) — DataPartStorage 的类型。可能值:Packed - 所有文件都存储在单个 blob 中;Full - 每个文件对应一个 blob。
  • disk_name (String) — 数据分区片段所在的磁盘名称。
  • path_on_disk (String) — 存放数据分区片段文件的文件夹的绝对路径。
  • rows (UInt64) — 数据分区片段中的行数。
  • size_in_bytes (UInt64) — 磁盘上数据分区片段的大小,以字节为单位。
  • merged_from (Array(String)) — 构成当前 part 的源 parts 名称数组。
  • bytes_uncompressed (UInt64) — 结果 part 的未压缩大小 (以字节为单位) 。
  • read_rows (UInt64) — 合并过程中读取的行数。
  • read_bytes (UInt64) — 在合并期间读取的字节数。
  • peak_memory_usage (UInt64) — 合并期间使用的 RAM 最大值
  • deduplication_block_ids (Array(String)) — 插入该 part 时用于去重的块 ID 数组。
  • error (UInt16) — 该异常的错误代码。
  • exception (String) — 发生的错误的文本消息。
  • mutation_ids (Array(String)) — 对于类型为 MUTATE_PART_START 和 MUTATE_PART 的事件,应用于源 part (merged_from) 的 mutation ID 数组。
  • ProfileEvents (Map(LowCardinality(String), UInt64)) — 在此操作期间捕获的所有 profile events。
  • projections_duration_ms (Map(LowCardinality(String), UInt64)) — 各投影的合并/重建耗时,单位为毫秒。

别名:

  • ProfileEvents.NamesmapKeys(ProfileEvents) 的别名。
  • ProfileEvents.ValuesmapValues(ProfileEvents) 的别名。
  • namepart_name 的别名。

在首次向 MergeTree 表插入数据后,会创建 system.part_log 表。

示例

SELECT * FROM system.part_log LIMIT 1 FORMAT Vertical;
Row 1:
──────
hostname:                clickhouse.eu-central1.internal
query_id:
event_type:              MergeParts
merge_reason:            RegularMerge
merge_algorithm:         Vertical
event_date:              2025-07-19
event_time:              2025-07-19 23:54:19
event_time_microseconds: 2025-07-19 23:54:19.710761
duration_ms:             2158
database:                default
table:                   github_events
table_uuid:              1ad33424-f5f5-402b-ac03-ec82282634ab
part_name:               all_1_7_1
partition_id:            all
partition:               tuple()
part_type:               Wide
disk_name:               default
path_on_disk:            ./data/store/1ad/1ad33424-f5f5-402b-ac03-ec82282634ab/all_1_7_1/
rows:                    3285726 -- 3.29 million
size_in_bytes:           438968542 -- 438.97 million
merged_from:             ['all_1_1_0','all_2_2_0','all_3_3_0','all_4_4_0','all_5_5_0','all_6_6_0','all_7_7_0']
bytes_uncompressed:      1373137767 -- 1.37 billion
read_rows:               3285726 -- 3.29 million
read_bytes:              1429206946 -- 1.43 billion
peak_memory_usage:       303611887 -- 303.61 million
error:                   0
exception:
mutation_ids:
ProfileEvents:           {'FileOpen':703,'ReadBufferFromFileDescriptorRead':3824,'ReadBufferFromFileDescriptorReadBytes':439601681,'WriteBufferFromFileDescriptorWrite':592,'WriteBufferFromFileDescriptorWriteBytes':438988500,'ReadCompressedBytes':439601681,'CompressedReadBufferBlocks':6314,'CompressedReadBufferBytes':1539835748,'OpenedFileCacheHits':50,'OpenedFileCacheMisses':484,'OpenedFileCacheMicroseconds':222,'IOBufferAllocs':1914,'IOBufferAllocBytes':319810140,'ArenaAllocChunks':8,'ArenaAllocBytes':131072,'MarkCacheMisses':7,'CreatedReadBufferOrdinary':534,'DiskReadElapsedMicroseconds':139058,'DiskWriteElapsedMicroseconds':51639,'AnalyzePatchRangesMicroseconds':28,'ExternalProcessingFilesTotal':1,'RowsReadByMainReader':170857759,'WaitMarksLoadMicroseconds':988,'LoadedMarksFiles':7,'LoadedMarksCount':14,'LoadedMarksMemoryBytes':728,'Merge':2,'MergeSourceParts':14,'MergedRows':3285733,'MergedColumns':4,'GatheredColumns':51,'MergedUncompressedBytes':1429207058,'MergeTotalMilliseconds':2158,'MergeExecuteMilliseconds':2155,'MergeHorizontalStageTotalMilliseconds':145,'MergeHorizontalStageExecuteMilliseconds':145,'MergeVerticalStageTotalMilliseconds':2008,'MergeVerticalStageExecuteMilliseconds':2006,'MergeProjectionStageTotalMilliseconds':5,'MergeProjectionStageExecuteMilliseconds':4,'MergingSortedMilliseconds':7,'GatheringColumnMilliseconds':56,'ContextLock':2091,'PartsLockHoldMicroseconds':77,'PartsLockWaitMicroseconds':1,'RealTimeMicroseconds':2157475,'CannotWriteToWriteBufferDiscard':36,'LogTrace':6,'LogDebug':59,'LoggerElapsedNanoseconds':514040,'ConcurrencyControlSlotsGranted':53,'ConcurrencyControlSlotsAcquired':53}