# Storage Spilling

### Condition

Query in `RUNNING` status write too much temporary data on disk. Spilling is usually caused by very large sorts (DISTINCT, ROW\_NUMBER() window function, etc.).

### How to fix

* Consider adding more filters and processing smaller amount of data in one go.
* Consider adding more steps with explicit pre-aggregation before sorting to reduce its complexity.

### Example

```
    StorageSpillingCondition(
        min_local_spilling_gb=50,  # 50Gb spill to local storage
        min_remote_spilling_gb=1,  # 1Gb spill to remote storage
        warning_duration=60 * 10,  # 10 minutes for waring
        kill_duration=60 * 20,  # 20 minutes for kill
    ),
```

### Specific arguments

* **min\_local\_spilling\_gb** (int) - how much data should be spilled on local disk before condition matches, in gigabytes (recommended min value is at least 10Gb to prevent false positives)
* **min\_remote\_spilling\_gb** (int) - how much data should be spilled on remote disk before condition matches, in gigabytes (recommended value is 1Gb, since we do not want see remote spilling at all)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snowkill.net/condition/built-in-conditions/storage-spilling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
