Skip to main content

Database Model

This document explains where and how the gateway stores data. Refer to it when adjusting retention periods, managing disk space, or querying data directly.

The gateway has one Cassandra instance inside

Edge stores its data in a local Cassandra(127.0.0.1:9042, keyspace PE). This is separate from the Cassandra instance on the upper Platform (pp) — it is the gateway's own storage to keep collecting even when disconnected from the platform.

There are only 11 tables, divided into two categories.

PrefixPurpose
APP_Configuration — what to collect
TM_Time series and operational logs — collected data and collection history

APP_ — Collection Configuration

Everything created on the UI (Connection · Tag) is stored here as-is.

TableContent
APP_OPCConnection definition — OPC_ID · name · protocol (OPC_TYPE) · target IP/port · collection interval (TIMECYCLE) · auto-collection flag
APP_TAGTag definition — address to read and data type
Collection stops if these two disappear

Time series can be recollected, but configuration is human-made and cannot be recovered. Do not leave these two tables out of your backup → Backup.


TM_ — Collected Values and Operational Logs

TableContent
TM_TAG_POINTRaw collected values — the core of this storage
TM_TAG_POINT_ARCHIVEArchival copy
TM_TAG_ERRORPer-tag collection errors
TM_TAG_STATPer-tag statistics
TM_TAG_WRITEWrite (control) history
TM_OPC_STATPer-connection statistics
TM_PLC_PINGTarget equipment response confirmation history
TM_MONITORGateway resource and status
TM_API_LOGREST API call log

TM_TAG_POINT Structure

PRIMARY KEY (TAG_ID, TIMESTAMP)
WITH CLUSTERING ORDER BY (TIMESTAMP DESC)
PropertyValue
Partition keyTAG_ID — one tag per partition
ClusteringTIMESTAMP descending — reads from most recent first
ColumnsVALUE · QUALITY · ERROR_CODE · TYPE · ATTRIBUTE (map)
CompactionTimeWindowCompactionStrategy, 10-minute window
Why TimeWindow

The gateway only writes, reads briefly, and discards via TTL. By grouping SSTables into time windows, it can drop entire expired windows with almost no compaction cost.


Retention Period — The Number Appears in Two Places

The 30 days in the schema is not the actual value

scheme.cql has default_time_to_live of 30 days (2592000 seconds), but at startup the table TTL is ALTER TABLE with the edge.ttl value from app.properties, overriding it.

The factory default is edge.ttl = 60 (days), so actual retention is 60 days. Do not conclude it is 30 days by looking at the schema file alone.

To change it, edit edge.ttl and restart.

cd /opt/kopens/plantpulse-edge/bin
./config.sh --get edge.ttl
./config.sh --set edge.ttl 90
./config.sh --restart # 기동 시 ALTER TABLE 로 반영된다
Reducing it removes data immediately

If you reduce the TTL, data older than the new TTL will be reclaimed on the next compaction. This cannot be undone. If you are reducing it due to disk pressure, verify that required historical data has been sent to the upper platform before making the change.


When Disk Space Runs Out

Capacity is determined by number of tags × collection interval × retention days. You must reduce one of these three.

What to adjustHow
Retention daysReduce edge.ttl (see above)
Collection intervalIncrease TIMECYCLE on the connection — keep only tags that truly need per-second collection
Number of tagsDisable auto-collection on unused tags

For diagnostics, see Diagnostics.