> ## Documentation Index
> Fetch the complete documentation index at: https://docs.internal.nscale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Kusto: Deleting Records

> Delete records from Matrix staging tables and materialized views in Azure Kusto.

<Warning>
  **Archived — the legacy `netbox_matrix` agent is retired after the prod cutover.** Kept for
  historical reference only. For the live pipeline, see [Matrix Connector Operations](../../operator-guide/matrix-connector-operations).
</Warning>

Deleting records requires two commands — one for the staging table, one for the materialized view.
Deleting from staging alone does not affect the view, and vice versa.

## Procedure

```kql theme={null}
// 1. Preview (optional but recommended)
// whatif returns the number of records that would be deleted without actually deleting them.
// whatif does not require .disable — it is a read-only dry run.
.delete table <TableName>_staging records with (whatif=true) <|
  <TableName>_staging
  | where <condition>

.delete materialized-view <ViewName> records with (whatif=true) <|
  <ViewName>
  | where <condition>

// 2. Delete from staging (cleans unprocessed delta records)
.delete table <TableName>_staging records <|
  <TableName>_staging
  | where <condition>

// 3. Delete from view (cleans already-materialized records)
.disable materialized-view <ViewName>

.delete materialized-view <ViewName> records <|
  <ViewName>
  | where <condition>

.enable materialized-view <ViewName>

// 4. Verify
<ViewName>
| where <condition>
| count
```

<Warning>
  Re-enable the view as soon as the delete completes. While disabled, the materialization cycle is paused and all new records accumulate in the delta unprocessed. The larger the delta grows, the more work is required to reconcile it against the materialized part on resume, degrading both materialization and query performance.

  If the delete fails or is interrupted, re-enable the view immediately with `.enable materialized-view <ViewName>`, then investigate. The view will resume materializing from where it left off — the failed delete simply has no effect.
</Warning>

## Further Reading

* [Soft delete command](https://learn.microsoft.com/en-us/kusto/management/soft-delete-command?view=azure-data-explorer) — `.delete table` and `.delete materialized-view` syntax and examples
* [Data soft delete concepts](https://learn.microsoft.com/en-us/kusto/concepts/data-soft-delete?view=microsoft-fabric) — how soft delete works, limitations, and when to use it
* [Enable and disable materialized views](https://learn.microsoft.com/en-us/kusto/management/materialized-views/materialized-view-enable-disable?view=microsoft-fabric) — behaviour during disable, performance implications
* [How materialized views work](https://learn.microsoft.com/en-us/kusto/management/materialized-views/materialized-view-overview?view=microsoft-fabric) — materialized part vs delta explained
* [Materialized views limitations](https://learn.microsoft.com/en-us/azure/data-explorer/kusto/management/materialized-views/materialized-views-limitations) — why deleting from staging alone does not affect the view

## Permissions

`.delete` requires **Database Admin** permissions. Do not use `.purge` — it requires additional
cluster-level configuration and is intended for compliance use cases only.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.