> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/troubleshooting-and-resources/armory/how-tos/how-to-cleanup-old-executions-in-orca-mysql-database.md).

# How to Cleanup Old Executions in Orca MySQL Database

### Introduction <a href="#introduction" id="introduction"></a>

Some customers may have reasons for clearing old pipeline and task execution data out of Spinnaker, such as compliance requirements. This explains how to run a few queries to remove old pipeline and task execution data.Important Tables:

* orchestration\_stages: Task Stage Executions (ref back to orchestrations)\* orchestrations: Tasks (in Tasks tab)(e.g. Save Pipeline Task)\* pipeline\_stages: Stage Executions (ref back to pipelines)\* pipelines: Pipeline Executions

### Prerequisites <a href="#prerequisites" id="prerequisites"></a>

MySQL client access to the Orca database

### Instructions <a href="#instructions" id="instructions"></a>

#### To Remove Pipeline Executions: <a href="#to-remove-pipeline-executions" id="to-remove-pipeline-executions"></a>

Create temporary tables with the IDs of rows to remove: `CREATE TEMPORARY TABLE old_pipelines SELECT id FROM pipelines WHERE (updated_at / 1000)`

Remove rows:

```
DELETE FROM pipeline_stages WHERE id IN (SELECT id FROM old_pipeline_stages);
DELETE FROM pipelines WHERE id IN (SELECT id FROM old_pipelines);​
Cleanup the temporary tables:
DROP TABLE old_pipeline_stages;
DROP TABLE old_pipelines;​
```

#### To Remove Orchestration Executions (Tasks Tab): <a href="#to-remove-orchestration-executions-tasks-tab" id="to-remove-orchestration-executions-tasks-tab"></a>

Create temporary tables with the IDs of rows to remove: `CREATE TEMPORARY TABLE old_orchestrations SELECT id FROM orchestrations WHERE (updated_at / 1000)`

Remove rows:

```
DELETE FROM orchestration_stages WHERE id IN (SELECT id FROM old_orchestration_stages);
DELETE FROM orchestrations WHERE id IN (SELECT id FROM old_orchestrations);​
Cleanup the temporary tables:
DROP TABLE old_orchestration_stages;
DROP TABLE old_orchestrations;​
```
