DELETE¶
Delete rows from a Lance table using a predicate.
Syntax¶
Parameters¶
| Parameter | Description |
|---|---|
table_name |
Fully qualified table name: catalog.schema.table. |
condition |
Boolean expression to identify rows to delete. |
Examples¶
Delete by primary key¶
Delete with multiple conditions¶
Delete with IN clause¶
Delete with subquery¶
DELETE FROM lance.default.orders
WHERE customer_id IN (
SELECT id FROM lance.default.customers
WHERE status = 'inactive'
);
Delete all rows (use with caution)¶
Implementation¶
The Lance connector implements DELETE using a merge-on-read approach with deletion vectors:
- Rows matching the WHERE clause are identified by their row addresses
- A deletion vector is created marking these rows as deleted
- The deletion vector is committed to the dataset
- Subsequent reads automatically filter out deleted rows
This approach provides:
- Fast delete operations (no data rewriting)
- Efficient storage (only deletion markers are stored)
- Consistent reads (deleted rows are immediately invisible)
Limitations¶
- Concurrent deletes to the same table may cause conflicts
- DELETE without WHERE clause is not recommended; use DROP TABLE instead
- Very large deletion vectors may impact read performance over time