Documentation — Commands reference
Removes rows from a table.
delete from TABLE_NAME [ where CONDITION ];
where, all the rows go: delete from T; is the same as truncate table T;, but slower.DELETE privilege.The condition may contain a sub-query:
delete from visitors where id not in (select visitor_id from visit_history where last_meeting > now() - interval 1 year);
The sub-query is not a SynSQL query: each data broker runs it on its own partitions. If both tables have the same hash key (the visitor's id) and the same number of partitions, the result is the one you expect. In other designs, you can delete a visitor whose recent visit is stored on another data broker.
With a where, the server first reads the hash key and the columns of the condition to find the rows, then deletes them one by one by their key. On a big table, this takes time. Without where it empties the table at once.
The answer says how many rows were deleted.