跳到主要内容

数据库模型

本文件定义了 Platform 将数据存储在何处以及以何种形式存储。在确定备份范围、直接查询数据或调整保留周期时请参阅此文档。

并非单一存储类型

Platform 根据数据的特性采用异构存储(polyglot persistence)。如果不清楚哪些数据存储在何处,备份将无法完整执行。

存储存储内容规模
PostgreSQL主数据 · 配置 · 事务pp 模式 169 张表 + 现场应用 pf 模式
Aster TSDB (pp)时序 · 事件 · 聚合 · KPI125 张表
Iceberg (spark.plantpulse)长期保存 · 分析1 张表

PostgreSQL — 主数据与配置​

用于存储关系型数据。模式变更由 Flyway 管理,历史记录保存在 flyway_schema_history_v2 中。

表名大部分以 mm_ 前缀(master/meta)开头,共 159 张。按组分的完整列表请参阅 下方。

组代表性表
组织·资产mm_asset_tree · mm_enterprise · mm_site · mm_area · mm_line · mm_equipment · mm_asset_class
采集定义mm_opc · mm_tag · mm_point · mm_edge
报警mm_alarm · mm_alarm_config · mm_alarm_delivery · mm_alarm_suppressed · mm_alarm_shelve · mm_alarm_out_of_service
生产mm_order · mm_order_oee · mm_product · mm_shift · mm_calendar
维护·故障mm_maintenance_order · mm_maintenance_plan · mm_failure_record
人员·供应商mm_employee · mm_customer
安全mm_security · mm_token · user_login · user_login_session

关系 — 资产与采集​

mm_asset_tree 一张表中包含了 企业(E) → 站点(S) → 区域(A) → 产线(L) → 设备(M) 共五个层级。 像名称、描述、设备分类、运行状态、外部编号等 所有层级共有的字段仅在 Tree 表中 存在 —— mm_site 中没有 site_name,mm_enterprise 中也没有 enterprise_name。各层级特有的字段位于 1:1 扩展表(mm_enterprise · mm_site · mm_area · mm_line · mm_equipment)中,删除 Tree 表行时会同步删除。

规则执行方式
父级必须是上一层级,且区域以下必须属于同一站点外键 fk_mm_asset_tree_parent · fk_mm_asset_tree_parent_site
根节点仅限企业,企业无 site_id,站点的 site_id 为其自身CHECK 约束
各层 ID 格式 — 正式前缀或旧版 ASSET_CHECK chk_asset_id
仅设备可接收的字段(工单·维护·日历等)指向 mm_equipment 的外键

位置路径由视图 mv_path 提供 — 每个节点包含 asset_type · depth(企业 0 ~ 设备 4) · enterprise_id · site_id · area_id · line_id · equipment_id · id_path · name_path。

关系 — 报警​

关系 — 生产与用户​

外键维护完整性

上述关系大部分通过外键声明。因此,直接 DELETE 被引用的行将被拒绝,或者根据表定义同步删除 (ON DELETE CASCADE)。请通过界面或 API 进行删除操作。

全表 (169)​

组表
组织·资产 (29)mm_area · mm_area_function · mm_asset_class · mm_asset_class_iso_class · mm_asset_connection_status · mm_asset_document · mm_asset_health_status · mm_asset_layout · mm_asset_plan_generation · mm_asset_plan_segment · mm_asset_qr_access_audit · mm_asset_qr_token · mm_asset_relation · mm_asset_standard_profile · mm_asset_status · mm_asset_tree · mm_asset_type · mm_canvas · mm_enterprise · mm_equipment · mm_equipment_criticality · mm_image · mm_line · mm_line_kind · mm_operational_status · mm_site · mm_stats_site · mm_stats_system · mm_status
采集定义 (11)mm_edge · mm_edge_status_snapshot · mm_opc · mm_opc_connection_status · mm_opc_latency_status · mm_opc_protocol · mm_opc_source_type · mm_point · mm_tag · mm_tag_java_type · mm_tag_type
报警 (16)mm_alarm · mm_alarm_cause · mm_alarm_config · mm_alarm_config_recipient · mm_alarm_config_revision · mm_alarm_delay · mm_alarm_delivery · mm_alarm_label_revision · mm_alarm_notification · mm_alarm_out_of_service · mm_alarm_resolution_guide · mm_alarm_resolution_guide_cause · mm_alarm_shelve · mm_alarm_signal_gap · mm_alarm_suppressed · mm_tag_alarm_recipient
设备指令·声明 (13)mm_asset_command · mm_asset_command_revision · mm_asset_statement · mm_asset_statement_deployment · mm_asset_statement_plugin · mm_asset_statement_revision · mm_command_area · mm_command_execution · mm_command_execution_event · mm_command_switch · mm_command_switch_audit · mm_event · mm_event_attributes
生产 (35)mm_calendar · mm_calendar_revision · mm_calendar_type · mm_defect_cause · mm_defect_record · mm_defect_record_revision · mm_holiday · mm_order · mm_order_ems · mm_order_flow · mm_order_note · mm_order_oee · mm_order_pause · mm_order_performance · mm_order_progress · mm_order_quantity_correction · mm_order_quantity_correction_revision · mm_order_ram · mm_order_revision · mm_process_segment · mm_process_segment_asset · mm_product · mm_product_route · mm_product_standard_profile · mm_production_target · mm_shift · mm_shift_override · mm_shift_pattern · mm_shift_pattern_asset · mm_shift_pattern_slot · mm_shift_schedule_revision · mm_shift_slot_break · mm_stop_cause · mm_stop_reason · mm_stop_reason_revision
维护·故障 (25)mm_failure_record · mm_failure_record_change · mm_failure_record_label · mm_failure_record_link · mm_fault_cause · mm_fault_cause_alarm_cause · mm_fault_code_map · mm_fault_code_map_history · mm_iso_detection_method · mm_iso_equipment_category · mm_iso_equipment_class · mm_iso_failure_cause · mm_iso_failure_mechanism · mm_iso_failure_mode · mm_iso_failure_mode_class · mm_iso_maintainable_item · mm_iso_maintainable_item_class · mm_iso_maintenance_activity · mm_maintenance_attachment · mm_maintenance_code_map · mm_maintenance_code_map_history · mm_maintenance_order · mm_maintenance_order_revision · mm_maintenance_plan · mm_maintenance_plan_revision
人员·供应商 (10)mm_app_account · mm_app_account_audit · mm_app_account_revision · mm_app_account_scope · mm_customer · mm_employee · mm_employee_audit · mm_employee_emergency_contact · mm_employee_photo · mm_employee_qualification
流程 (5)mm_flow · mm_flow_health_status · mm_flow_link · mm_flow_node · mm_flow_snapshot
安全 (3)mm_security · mm_security_asset_scope · mm_token
其他 (22)mm_blob · mm_config · mm_diagnostic_code · mm_diagnostic_state · mm_metadata · mm_query_history · mm_reference_external_key · mm_reference_revision · mm_reference_text · mm_report · mm_schedule_fire_log · mm_schedule_watermark · dual · edge_active_flows · flow_snapshots · flyway_schema_history_v2 · metadata · node_component · user_login · user_login_session · version · version_history

Aster TSDB — 时序与事件​

Keyspace 为 pp。125 张表分为两大类。

前缀数量含义
tm_117时序·聚合·统计·KPI (time series measurement)
ts_8通用时序引擎内部结构

tm_ 根据对象再次细分 — 标签 32 · KPI 26 · 资产 17 · 系统 6 · 监控 6 · 选项 5 OPC 5 · 站点 3 · blob 3 等。

核心表 — tm_tag_point​

用于存储原始采集值。其余标签表大多由此衍生。

PRIMARY KEY (tag_id, timestamp)
WITH CLUSTERING ORDER BY (timestamp DESC)
属性值
分区键tag_id — 每个标签为一个分区
聚簇键timestamp 降序 — 默认从最新开始读取
默认 TTL315360000 秒 = 3650天(10年) — 值的正本位于 storage.tag.point.ttl (保留周期设置)
压缩UnifiedCompactionStrategy (Cassandra 5.0+ 功能)
索引asset_id · opc_id 采用 SAI(Storage Attached Index)
为何设有 static 列

site_id · asset_id · line_id · area_id · opc_id · tag_name · type 为 static 类型。由于同一个标签(=一个分区)内的值相同,因此每个分区仅存储一次。无需在每个数据点重复存储,从而大幅降低容量需求。

衍生表 — 预计算存储​

由于 Aster TSDB 在查询时进行实时聚合成本较高,因此在写入时预先创建。这也是表数量较多的原因。

类别示例
聚合tm_tag_point_aggregation_{1,5,10,30}_minutes · _1_hours
采样tm_tag_point_sampling_{10,30}_seconds · _{1,5,10,30}_minutes · _1_hours
计数tm_tag_point_count · _by_date · _by_opc · _by_site
质量·校验tm_tag_point_validation · _by_timestamp · _validation_count
AI 分析tm_tag_point_anomalies · _forecasts
快照·存档tm_tag_point_snapshot · tm_tag_point_archive

报警也采用相同模式 — tm_tag_alarm 与 _count · _count_by_date · _count_by_opc _count_by_site · _duration · _on。

请勿直接删除聚合表

聚合表无法从原始数据重新生成。删除后,对应时间段的界面和报表将显示为空,只能通过备份恢复。

KPI 表 — OEE · RAM · EMS​

设备 KPI (OEE · RAM · EMS) 存储在以 tm_kpi_ 开头的 26 张表中 — 按领域分为 tm_kpi_oee_* · tm_kpi_ram_* · tm_kpi_ems_*。计算作业约每 10 秒为每台设备计算并写入一次值。

旧版 tm_asset_oee* · tm_asset_ram* · tm_asset_ems* 表已失效

KPI 现在仅写入新表。使用旧名称查询的 SQL 或报表必须根据新表和分区键进行修改。由于键已更改,直接迁移旧条件不会报错,而是容易产生 空结果,且该空结果无法与「无数据」状态区分。

表根据形态分为四类。

类别名称主键单行含义
当前值tm_kpi_*_current(asset_id)设备的 当前 值 — 每设备一行,每次计算时覆盖写入
按工单tm_kpi_oee_order · tm_kpi_ems_order(order_id)单个工作工单的值 — 每工单一行,工单结束后保留
历史tm_kpi_*_history 等((asset_id, day), timestamp)单次计算 (Tick) 的值 — UTC 日期 分区,最新在前
汇总tm_kpi_*_rollup((scope, scope_id, day), timestamp)按产线 · 区域 · 站点 · 企业单位汇总的值
  • Bucket 为 UTC 日期。 day 为 yyyymmdd, month 为 yyyymm 整数,行中的 timestamp 为视为 UTC 的日期 — 并非站点当地子夜。因此,当地的一天会跨越 两个 UTC Bucket(例如韩国时间 00:00 ~ 08:59 的行位于前一天的 UTC Bucket 中)。
  • 低频数据采用月 Bucket — 设备状态(tm_kpi_oee_status)、故障 (tm_kpi_ram_failure · _failure_rollup)、燃料(tm_kpi_ems_fuel) 使用 month 进行分区。
  • 汇总表的 scope 取值为 LINE · AREA · SITE · ENTERPRISE 之一,scope_id 为该产线·区域·站点的 ID。企业单位使用 scope_id = 'ALL'。
  • 原因计数器 tm_kpi_oee_defect_cause · _stop_cause · _fault_cause 为不良 · 停机 · 故障原因的日累计值。主键为 ((asset_id, month), date, cause_code)。
  • 历史行采用工单累积值。 *_history 的一行表示截至该 Tick 的工单总计值(运行时间 · 产量 · 能源等)。请勿对行进行求和 — 如需期间值,请读取每个工单的最后一行或 *_order 行。
  • 设备状态的持续时间不单独存储。 tm_kpi_oee_status 仅记录状态 变更时间,一个状态持续至下一行的时间点。在跨月边界读取时,请连续读取 Bucket 而非将其截断。
查询 — 请提供完整分区键

将 asset_id 与 day (或 month) 全部 放入查询条件中。请勿使用 ALLOW FILTERING。查询时间段时,将时间段展开为 UTC 日期列表,每个 Bucket 读取一次。

SELECT timestamp, oee, availability, performance, quality
FROM pp.tm_kpi_oee_history
WHERE asset_id = 'EQUIPMENT_000001' AND day = 20260925
AND timestamp >= '2026-09-25 00:00:00+0000';

如需获取站点下各设备的值,请先从 PostgreSQL 获取设备列表,然后为每台设备读取 tm_kpi_*_current。站点合计值位于汇总表的 scope = 'SITE'。

保留周期为 5 年。 含有 Bucket 的表(历史 · 事件 · 状态 · 汇总等)默认 TTL 为 157680000 秒 (1825天),值的正本位于 storage.asset.kpi.ttl (若无则为 storage.asset.standard.ttl) (保留周期设置)。当前值(*_current) · 按工单(*_order) · 原因计数器无 TTL。14 张历史类表每日同步至 Iceberg 的 tw_kpi_*,因此在 Aster TSDB 过期删除后,仍可通过 Iceberg 查询。


分区逻辑 — 分区键即查询维度​

Aster TSDB 不支持 Join。根据查询方式分别建立表 — 这就是为什么有 125 张表。同一数据以不同分区键存储在多张表中并非重复,而是设计使然。

分区键形式适用场景示例
(tag_id) + timestamp单个标签的时间轴查询tm_tag_point
(asset_id, date, hour) + timestamp单个设备的一日/一小时区间tm_asset_data
(asset_id, day) + timestamp单个设备的 UTC 日 KPItm_kpi_oee_history
(scope, scope_id, day) + timestamp产线·区域·站点·企业的 UTC 日 KPItm_kpi_oee_rollup
(site_id, year, month, day)站点单位聚合tm_site_summary
仅 (id)当前值 — 无时间轴,因此无过期时间*_count, *_last_update, tm_kpi_*_current

全表 (125)​

标签 · 数据点 (32)​

表主键 (分区 · 聚簇)
tm_tag_alarmtag_id, alarm_seq
tm_tag_alarm_count``
tm_tag_alarm_count_by_datetag_id, year, month, day, hour, minute
tm_tag_alarm_count_by_opc(opc_id, tag_id), year, month, day, hour, minute
tm_tag_alarm_count_by_site(site_id, tag_id), year, month, day, hour, minute
tm_tag_alarm_durationalarm_config_id, alarm_seq
tm_tag_alarm_on``
tm_tag_pointtag_id, timestamp
tm_tag_point_aggregation_10_minutestag_id, timestamp
tm_tag_point_aggregation_1_hourstag_id, timestamp
tm_tag_point_aggregation_1_minutestag_id, timestamp
tm_tag_point_aggregation_30_minutestag_id, timestamp
tm_tag_point_aggregation_5_minutestag_id, timestamp
tm_tag_point_anomaliesjob_id, timestamp, tag_id
tm_tag_point_archive(site_id, year, month, day, hour), minute, second, tuuid
tm_tag_point_count``
tm_tag_point_count_by_datetag_id, year, month, day, hour, minute
tm_tag_point_count_by_opc``
tm_tag_point_count_by_site``
tm_tag_point_forecastsjob_id, timestamp, tag_id
tm_tag_point_map(year, month, day, hour, minute), timestamp
tm_tag_point_sampling_10_minutestag_id, timestamp
tm_tag_point_sampling_10_secondstag_id, timestamp
tm_tag_point_sampling_1_hourstag_id, timestamp
tm_tag_point_sampling_1_minutestag_id, timestamp
tm_tag_point_sampling_30_minutestag_id, timestamp
tm_tag_point_sampling_30_secondstag_id, timestamp
tm_tag_point_sampling_5_minutestag_id, timestamp
tm_tag_point_snapshot(site_id, snapshot_id, date), timestamp
tm_tag_point_validationtag_id, timestamp
tm_tag_point_validation_by_timestampyyyymmdd, timestamp, tag_id
tm_tag_point_validation_counttag_id, year, month, day, hour, minute

资产 (17)​

表主键 (分区 · 聚簇)
tm_asset_aggregationasset_id, timestamp
tm_asset_alarmasset_id, alarm_seq
tm_asset_commandasset_id, timestamp
tm_asset_connection_statusasset_id, timestamp
tm_asset_contextasset_id, timestamp
tm_asset_data(asset_id, date, hour), timestamp
tm_asset_data_anomaliesjob_id, timestamp, asset_id, tag_id
tm_asset_data_based_dayasset_id, timestamp
tm_asset_data_based_hourasset_id, timestamp
tm_asset_data_based_minute(asset_id, date), timestamp
tm_asset_data_based_second(asset_id, date, hour), timestamp
tm_asset_data_based_timestamp(asset_id, date, hour), timestamp
tm_asset_data_forecastsjob_id, timestamp, asset_id, tag_id
tm_asset_eventasset_id, timestamp
tm_asset_health_statusasset_id, timestamp
tm_asset_statusasset_id, timestamp
tm_asset_timelineasset_id, timestamp, timeline_group, timeline_type

KPI — OEE · RAM · EMS (26)​

Bucket 列中的「日」为 day (UTC yyyymmdd),「月」为 month (UTC yyyymm)。 原因计数器的 month 从 date 中获取。读取方法请参阅 KPI 表 节。

表主键 (分区 · 聚簇)Bucket内容
tm_kpi_oee_currentasset_id—设备的当前 OEE
tm_kpi_oee_orderorder_id—单个工作工单的 OEE
tm_kpi_oee_history(asset_id, day), timestamp日每次计算 Tick 的 OEE (工单累积)
tm_kpi_oee_event(asset_id, day), timestamp日OEE 输入事件
tm_kpi_oee_count(asset_id, day), timestamp日良品 · 不良产量 (Lot · Serial)
tm_kpi_oee_rolling(asset_id, day), timestamp日最近 N 分钟 OEE
tm_kpi_oee_rollup(scope, scope_id, day), timestamp日产线 · 区域 · 站点 · 企业 OEE
tm_kpi_oee_status(asset_id, month), timestamp月设备状态变更
tm_kpi_oee_status_currentasset_id—设备的直接前一状态
tm_kpi_oee_defect_cause(asset_id, month), date, cause_code月不良原因日累积 (计数器)
tm_kpi_oee_stop_cause(asset_id, month), date, cause_code月停机原因日累积 (计数器)
tm_kpi_oee_fault_cause(asset_id, month), date, cause_code月故障原因日累积 (计数器)
tm_kpi_ram_currentasset_id—设备的当前 RAM
tm_kpi_ram_history(asset_id, day), timestamp日每次计算 Tick 的 RAM (工单累积)
tm_kpi_ram_failure(asset_id, month), timestamp月故障开始 · 结束事件
tm_kpi_ram_failure_rollup(scope, scope_id, month), timestamp, asset_id月产线 · 区域 · 站点故障事件
tm_kpi_ram_rolling(asset_id, day), timestamp日最近 N 分钟 RAM
tm_kpi_ram_rollup(scope, scope_id, day), timestamp日产线 · 区域 · 站点 · 企业 RAM
tm_kpi_ems_currentasset_id—设备的当前 EMS
tm_kpi_ems_orderorder_id—单个工作工单的 EMS
tm_kpi_ems_history(asset_id, day), timestamp日每次计算 Tick 的 EMS (工单累积)
tm_kpi_ems_power(asset_id, day), timestamp日电力计量事件 (kW · kWh)
tm_kpi_ems_power_rollup(scope, scope_id, day), timestamp, asset_id日产线 · 区域 · 站点电力事件
tm_kpi_ems_fuel(asset_id, month), timestamp月燃料计量事件 (Scope 1)
tm_kpi_ems_rolling(asset_id, day), timestamp日最近 N 分钟 EMS
tm_kpi_ems_rollup(scope, scope_id, day), timestamp日产线 · 区域 · 站点 · 企业 EMS

采集 · 站点 (8)​

表主键 (分区 · 聚簇)
tm_opc_connection_latency_historyopc_id, timestamp
tm_opc_connection_status_historyopc_id, timestamp
tm_opc_point_count``
tm_opc_point_count_by_dateopc_id, year, month, day, hour, minute
tm_opc_point_last_update``
tm_site_statussite_id, timestamp
tm_site_summarysite_id, year, month, day, hour, minute
tm_site_summary_total``

监控 (13)​

表主键 (分区 · 聚簇)
tm_monitor_cep_metricstype, timestamp
tm_monitor_cluster_metricstype, ip, timestamp
tm_monitor_cluster_statustype, ip, timestamp
tm_monitor_nodestype, ip
tm_monitor_platform_healthtype, ip, timestamp
tm_monitor_platform_statustype, ip, timestamp
tm_system_health_statusapp_name, timestamp
tm_system_logapp_name, timestamp, seq
tm_system_log_count(app_name, level), year, month, day, hour, minute
tm_system_log_hourlyapp_name, bucket_start, instance_id, level
tm_system_propertiesproperty, timestamp
tm_system_start_date``
tm_system_trendyear, month, day, hour

批处理 · 审计 (4)​

表主键 (分区 · 聚簇)
tm_batch_audityyyymmdd, timestamp, id
tm_batch_job_runyyyymmdd, timestamp, id
tm_warehouse_audityyyymmdd, timestamp, id
tm_warehouse_storage_usage_dailyyear_bucket, day, table_name

时序引擎 (TSE 专用) (8)​

表主键 (分区 · 聚簇)
ts_data_pointskey, column1
ts_row_key_indexkey, column1
ts_row_key_time_indexmetric, table_name, row_time
ts_row_keys(metric, table_name, row_time), data_type, tags
ts_service_index(service, service_key), key
ts_specspec_type, name
ts_string_indexkey, column1
ts_tag_indexed_row_keys(metric, table_name, row_time, single_tag_pair), data_type, tag_collection_hash, tags

其他 (17)​

表主键 (分区 · 聚簇)
tm_blobblob_id, timestamp
tm_blob_count_and_size``
tm_blob_object``
tm_data_gateway_count``
tm_data_gateway_loglang, timestamp
tm_database_sizekeyspace_name, date
tm_diagnosticyear, timestamp
tm_diagnostic_countyear, level
tm_domain_change_history(domain_type, object_id), timestamp
tm_edge_status``
tm_option_eql_listener_result``
tm_option_eql_statement``
tm_option_eql_statement_historystmt_name, timestamp
tm_option_job_trigger_historyjob_name, context_fire_time
tm_option_listener_push_cacheurl, timestamp
tm_pipeline_exception_historybucket, timestamp, type, object_id
tm_trigger_resulttrigger_id, timestamp

Iceberg — 长期保存​

将归档表(tm_tag_point_archive, 默认 365 天)的数据堆叠至对象存储进行分析。数据并非直接从原始表迁移,而是经过归档流程。

项目值
目录spark.plantpulse
表tw_tag_point — 标签时序。包含以 tw_asset_* · tw_blob 等 tw_ 开头的 9 种类型。KPI 另有 14 种 tw_kpi_*
分区site_id → year → month → day
格式Iceberg v2 (支持行级删除)
压缩Zstandard
执行Spark SQL

KPI 归档 — tw_kpi_*​

KPI 不经过归档表,而是直接从 tm_kpi_* 迁移。每日凌晨复制前一日数据,因此近期数据同时存在于 Aster TSDB 和 Iceberg 中,超过 5 年 (TTL) 的数据仅保留在 Iceberg 中。Iceberg 端不执行删除。分区为 year → month → day (月 Bucket 表为 year → month)。

Aster TSDBIceberg
tm_kpi_oee_history · _event · _count · _status · _rolluptw_kpi_oee_history · _event · _count · _status · _rollup
tm_kpi_ram_history · _failure · _rollup · _failure_rolluptw_kpi_ram_history · _failure · _rollup · _failure_rollup
tm_kpi_ems_history · _power · _fuel · _rollup · _power_rolluptw_kpi_ems_history · _power · _fuel · _rollup · _power_rollup

当前值(*_current · oee_status_current) · 按工单(*_order) · 最近 N 分钟(*_rolling) · 原因计数器(*_cause) 不予迁移 — 因为它们不属于历史数据,或可由历史数据重新计算得出。

如需查找超过保留周期的数据

此类数据在 Aster TSDB 中已不存在。请查询 Iceberg 端 → 分析层。各表的保留周期请参阅 数据保留周期(TTL)设置。


备份中容易遗漏的事项​

三个存储单元分别作为备份对象。若仅备份 PostgreSQL 可能会导致时序数据全部丢失。

存储遗漏后果
PostgreSQL设备·标签定义、用户、仪表盘丢失
Aster TSDB保留周期内的时序数据丢失
Iceberg / 对象存储长期历史记录丢失

具体流程请参阅 备份与恢复。


相关文档​