Database Model
This document explains where and in what shape the gateway stores data. Refer to it when adjusting the retention period, when the disk fills up, or when you need to query directly.
Edge stores its own data in local Cassandra (127.0.0.1:9042, keyspace PE).
This is different from the Cassandra on the upper platform (pp) — it is a self-contained store that lets the gateway keep collecting on its own even if it loses connection.
There are only 11 tables, split into two groups.
| Prefix | Meaning |
|---|---|
APP_ | Configuration — what to collect |
TM_ | Time series / operational records — what was collected and how |
APP_ — Collection configuration
Whatever you create on the screens (connection · tag) goes straight in here.
| Table | Contents |
|---|---|
APP_OPC | Connection definitions — OPC_ID · name · protocol (OPC_TYPE) · target IP/port · collection interval (TIMECYCLE) · auto-collect flag |
APP_TAG | Tag definitions — address to read and data type |
Time series data can be re-collected, but configuration is something a person created, so there is no way to recover it. Don't forget these two tables when backing up → Backup and Recovery.
TM_ — Collected values and operational records
| Table | Contents |
|---|---|
TM_TAG_POINT | Raw collected values — the core of this store |
TM_TAG_POINT_ARCHIVE | Archival copy |
TM_TAG_ERROR | Per-tag collection errors |
TM_TAG_STAT | Per-tag statistics |
TM_TAG_WRITE | Write (control) history |
TM_OPC_STAT | Per-connection statistics |
TM_PLC_PING | Target equipment response check history |
TM_MONITOR | Gateway resources/status |
TM_API_LOG | REST API call log |
Shape of TM_TAG_POINT
PRIMARY KEY (TAG_ID, TIMESTAMP)
WITH CLUSTERING ORDER BY (TIMESTAMP DESC)
| Property | Value |
|---|---|
| Partition key | TAG_ID — one tag = one partition |
| Clustering | TIMESTAMP descending — reads start from the latest |
| Columns | VALUE · QUALITY · ERROR_CODE · TYPE · ATTRIBUTE (map) |
| Compaction | TimeWindowCompactionStrategy, 10-minute window |
For the gateway, the workflow is simply "write, briefly read, then discard via TTL." By grouping SSTables into time windows, an entire expired window can be discarded as a whole, keeping compaction cost near zero.
Retention period — the number exists in two places
The default_time_to_live in scheme.cql is 30 days (2592000 seconds), but at startup it is
overwritten by ALTER TABLE the table TTL with the edge.ttl value from app.properties.
Since the factory default is edge.ttl = 60 (days), the actual retention is 60 days.
Don't assume 30 days just by looking at the schema file.
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 로 반영된다
If you shorten the TTL, data older than the new value gets reclaimed on the next compaction. This cannot be undone. If you're shortening it because disk space is running out, make sure you've uploaded any needed range to the upper platform first.
When the disk fills up
Capacity is determined by number of tags × collection interval × retention days. You need to reduce one of the three.
| What to adjust | How |
|---|---|
| Retention days | Reduce edge.ttl (see above) |
| Collection interval | Increase TIMECYCLE on the connection — keep second-level collection only for tags that truly need it |
| Number of tags | Turn off auto-collect for unused tags |
For diagnostics, see Diagnostics and Inspection.
Related documents
- Backup and Recovery — what you need to back up
- app.properties Reference — keys including
edge.ttl - Monitoring
- Point Search — querying time series from the screen