# IRPCVaultsAdmin.OptimizeVaultMetaDataDatabase

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Administration API](https://developer.m-files.com/APIs/gRPC-API/admin/index.md) > [Vault management](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultsAdmin/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultsAdmin/OptimizeVaultMetaDataDatabase/

Badges: `Administration API / specialized` `admin` `session`

Optimizes the metadata database of a vault.

- **Service:** [Vault management](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultsAdmin/index.md) `MFiles.IRPCVaultsAdmin`
- **gRPC method:** `/MFiles.IRPCVaultsAdmin/OptimizeVaultMetaDataDatabase`
- **HTTP (mf-http-grpc):** `POST /grpc/v1/optimize-vault-meta-data-database`
- **Request:** [`OptimizeVaultMetaDataDatabaseRequest`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultsAdmin/OptimizeVaultMetaDataDatabase/index.md#request)
- **Response:** [`OptimizeVaultMetaDataDatabaseResponse`](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCVaultsAdmin/OptimizeVaultMetaDataDatabase/index.md#response)
- **Book and level:** Administration API, specialized
- **Kind:** admin
- **Session:** Required: the session ID from LogIn in the mfiles-session-id-bin metadata.
- **Idempotent:** no
- **Returns metadata structure version:** no
- **Streaming:** none (unary)

<a id="remarks"></a>

## Remarks

- **Starts a background job and returns before it completes**; follow it with `task_id` (see the
  service overview). A thorough optimization (`flags.is_thorough`) takes the vault offline while
  it runs; a quick one does not.
- With a server-level session, requires the system administrator server role (server right
  `manage_vaults`) and creates a server-level job.
- With a vault session, requires the vault right `manage_scheduled_jobs` and creates a job of
  that vault; follow it with a session of the same vault.

<a id="request"></a>

## Request: OptimizeVaultMetaDataDatabaseRequest

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `optimize_vault_job` | [`OptimizeVaultJob`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OptimizeVaultJob/index.md) | The optimization to run: the vault (`vault_guid`), quick or thorough (`flags.is_thorough`), whether to garbage-collect files of destroyed objects (`flags.garbage_collect_files`), and when to cancel automatically. |
| `optimize_vault_job.vault_guid` | `string` | The GUID of the vault. |
| `optimize_vault_job.flags` | [`OPTIMIZEVAULTFLAGS`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OPTIMIZEVAULTFLAGS/index.md) | Flags that control the execution of this job. |
| `optimize_vault_job.flags.all` | `bool` | Specifies all flags set; Including any future flags. |
| `optimize_vault_job.flags.is_thorough` | `bool` | Thorough or quick optimization? In quick mode, only the indexes of the metadata database are refreshed. Thorough optimization performs a garbage-collection in the database and rebuilds indexes. The quick mode optimization is an online activity whereas the thorough mode optimization takes the vault offline. |
| `optimize_vault_job.flags.garbage_collect_files` | `bool` | Directs the optimization job to destroy garbage-collected data files that stand for destroyed objects. |
| `optimize_vault_job.auto_cancel_options` | [`OptimizeVaultAutoCancelOptions`](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.OptimizeVaultAutoCancelOptions/index.md) | Auto-cancel options. |
| `optimize_vault_job.auto_cancel_options.auto_cancel` | `bool` | True if auto-cancel is enabled. |
| `optimize_vault_job.auto_cancel_options.auto_cancel_day` | [`Weekday`](https://developer.m-files.com/APIs/gRPC-API/Reference/Enums/MFiles.Weekday/index.md) | Day when the job is auto-cancelled. Values: `WEEKDAY_NONE` (0), `WEEKDAY_MONDAY` (1), `WEEKDAY_TUESDAY` (2), `WEEKDAY_WEDNESDAY` (3), `WEEKDAY_THURSDAY` (4), `WEEKDAY_FRIDAY` (5), `WEEKDAY_SATURDAY` (6), `WEEKDAY_SUNDAY` (7). |
| `optimize_vault_job.auto_cancel_options.auto_cancel_time` | [`google.protobuf.Timestamp`](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp) | Time when the job is auto-cancelled. |
| `optimize_vault_job.auto_cancel_options.continuable` | `bool` | True if a cancelled optimization job can be continued on the next run. |

<a id="response"></a>

## Response: OptimizeVaultMetaDataDatabaseResponse

> Nested message fields are expanded to depth 3; follow a type link for deeper levels and for the type's own page.

| Field | Type | Description |
|---|---|---|
| `task_id` | `int32` | The ID of the scheduled job that runs the optimization. |
