Skip to content

Delete rows older than a chosen boundary ​

Coordinator DB removes rows with ordinary DELETE ... WHERE. It does not require a background mutation command for this operation. Define the retention boundary in the same value domain as the stored column and preview the matching rows before deleting them.

For an application that stores a numeric sequence boundary, the shape is:

sql
SELECT count(*) FROM events WHERE sequence_id < 1000;

Use the exact same predicate for the reviewed change:

sql
BEGIN;
DELETE FROM events WHERE sequence_id < 1000;
COMMIT;

Make the retention rule explicit ​

For dates and timestamps, agree on timezone, precision and whether the boundary is inclusive. A calendar label such as “last month” is not enough to define an unambiguous predicate. Preserve a verified copy if recovery of deleted data may be required.

A native connection retains transaction state. With HTTP, BEGIN, DELETE and COMMIT must be in one request; an unclosed transaction rolls back before the response. A client losing the response must inspect the destination before repeating the action.

Deleting all rows retains the table definition. Use DROP only when removing the object itself is the intended operation, and review foreign-key effects when enforcement is enabled.

See DELETE, transactions and database copies.