# Garbage Collection

## How garbage is created

Doltgres creates on disk garbage. Doltgres transactions that do not have a corresponding Doltgres commit create on disk garbage. This garbage is most noticeable after large data imports.

Specifically, writes to Doltgres can result in multiple chunks of the [prolly\
tree](https://www.dolthub.com/blog/2020-04-01-how-dolt-stores-table-data) being rewritten,\
which [writes a large portion of the\
tree](https://www.dolthub.com/blog/2020-05-13-dolt-commit-graph-and-structural-sharing/#cant_share).\
When you perform write operations without committing or delete a branch containing novel\
chunks, garbage is created.

![How garbage is created](/files/louPYMUHgfB79pRVbEo3)

### Online

You can run garbage collection on your running SQL server using [`select dolt_gc`](/reference/version-control/dolt-sql-functions.md#dolt_gc) through any connected client.

NOTE: Performing GC on [a cluster replica](/reference/server/replication.md) which is in standby mode is not\
yet supported, and running `select dolt_gc()` on the replica will fail.

## Automated GC

Automated garbage collection is currently experimental and will be enabled by default in a release\
later this year. Check back for details.


---

# 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.doltgres.com/reference/server/garbage-collection.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.
