Delete data from DB with autogen retention policy

DROP SERIES FROM "%" WHERE "entity_id"='batt'

Also note that delete operations don’t happen immediately and can take time and a lot of system resources to complete. This has to do with how InfluxDB stores and compacts data over time. All data is stored in “shards”–time-based groupings of data. As shards gets older, InfluxDB performs different levels of compaction on them to optimize disk storage. Shards that are currently written to are considered “hot” and are not compacted. Compacted shards are considered “cold.” You can query cold shards, but it hurts query performance because it has to uncompact each shard and read the data out of it.

Deletes are essentially a query that has to scan shards to identify which shards match your delete predicate. The DROP SERIES command shown above is unbounded, meaning it’s not limited to a specific time range. So the request will have to scan all data, compacted or not, that matches the predicate.

All this to say… tread carefully. Careless, unbounded deletes have been known to take a database offline. Also, some delete requests can take a long time depending on how much data matches the predicate and how old/compacted that data is.

1 Like