# Free up space on your database

This procedure frees up disk space in a gradual process, which can take several days or weeks. Once all the steps have been completed, it will be necessary to temporarily increase the disk space in order to rebuild the database, thus recovering space and then reducing the disk size again.

{% hint style="info" %}
**Info**

Values are given as an example and must be modified according to your configurationyou.
{% endhint %}

{% hint style="success" %}
**Percona**

You can also use Percona to perform this type of operation on your databases. A [procedure](/tutorials/procedures/linux_percona_toolkit.md) is available to help&#x20;
{% endhint %}

## Initial configuration

Access the menu **`Setup`** > **`General`** > **`History Purge`** to set up the purging of the two main space-consuming sections: Software and Users.

Steps :

* Initial setup
* In the **Software** section, set all three fields to 60 months.
* In the **Users** section, set the four fields to 60 months for an initial test.

![alt text](/files/NTik2COFrkH48LeM0Jle)

![alt text](/files/WNtRpRpB4GYeMKSHOaZM)

## Automatic action configuration

From **`Setup`** > **`Automatic actions`**, configure **`purgelogs`** to run daily outside business hours.

Example schedule:

![alt text](/files/hjI2Z2RZUFOqjy5khj6u)

{% hint style="success" %}
**Automatic actions**

See the different [automatic actions](broken://spaces/QFOh36etagWOcP9q4ECb/pages/SIuOfxDtQlTSBswIpJLP#what-is-the-difference-between-logs-purgelogs-and-circularlogs-actions) related to logsInitial run
{% endhint %}

Let the automatic action run overnight.

Then check the Logs tab in the automatic action to verify the number of lines deleted.

## Gradual adjustment of parameters

Leave the automatic action running overnight.

Then check the Logs tab in the automatic action to see how many lines have been deleted.

## Gradual adjustment of parameters

Once the number of deleted lines reaches 0 or close to 0, gradually reduce the retention period (previously set to 60 months) to 55 months.

Repeat the cleaning steps until you reach the desired minimum history duration.

## Temporary increase in disk space

Once the cleanup is complete, it will be necessary to temporarily increase disk space (to almost double the current size) to perform the following operation.

## Database optimization

After deleting a large volume of data (e.g. from the glpi\_logs table), you may notice that the disk space used does not immediately decrease at file system level. This is normal due to the operation of the InnoDB storage engine.

Procedure: Run the following command to optimize the table and reclaim disk space:

**`ALTER TABLE <table_name> ENGINE=InnoDB;`**

This command rebuilds the table indexes while ensuring data security and freeing up unused space.


---

# 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://help.glpi-project.org/tutorials/procedures/free_database_space.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.
