数据表清空
💡 提示
数据表清空,时间短操作简单。
TRUNCATE ts_kv;
条件删除
💡 提示
根据数据量和过滤条件,执行时间可能很久。
1/3:执行删除语句
DELETE FROM ts_kv WHERE key= 点位的序号
DELETE FROM ts_kv WHERE ts= 时间,单位:毫秒
DELETE FROM ts_kv WHERE entity_id= 实体ID
-- 多条件组合
DELETE FROM ts_kv WHERE entity_id= 实体ID AND key= 点位的序号
SELECT key_id FROM ts_kv_dictionary WHERE key = 点位标识符
SELECT key_id FROM key_dictionary WHERE key = 点位标识符
SELECT id FROM device dev LEFT JOIN tk_organization org ON dev.organization_id = org.id WHERE name LIKE '%组织名字%'
2/3:清理空间
VACUUM ts_kv;
3/3:检查点存档
CHECKPOINT;