# How do I run optimize with pt-online-schema-change?

**URL:** <https://forums.percona.com/t/how-do-i-run-optimize-with-pt-online-schema-change/7284>\
**Category:** Percona Toolkit\
**Created:** [November 6, 2019, 2:52pm UTC](https://forums.percona.com/t/how-do-i-run-optimize-with-pt-online-schema-change/7284 "2019-11-06T14:52:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CESAR\_MURILO\_DA\_SILV](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cesar_murilo_da_silv/32/1248_2.png) [@CESAR\_MURILO\_DA\_SILV](https://forums.percona.com/u/CESAR_MURILO_DA_SILV)\
**Post date:** [November 6, 2019, 2:52pm UTC](https://forums.percona.com/t/how-do-i-run-optimize-with-pt-online-schema-change/7284/1 "2019-11-06T14:52:42Z")

</div>

I want to decrease the size of disk space occupied by some tables. For that, I want to run optimize (any better ideas?).

How would I optimize with the pt-online-schema-change command? The option would be --alter = “ENGINE = InnoDB”, same as shown below?

pt-online-schema-change --alter = “ENGINE=InnoDB” --analyze-before-swap --user= --password= --execute D=, t=;

I’m running the command like this, and the error is returning me:The new table `<database>` .`_ <table> _new` does not have a PRIMARY KEY or a unique index which is required for the DELETE trigger.Please check you have at least one UNIQUE and NOT NULLABLE index.

---

<div class="post-metadata">

**Author:** ![CESAR\_MURILO\_DA\_SILV](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/cesar_murilo_da_silv/32/1248_2.png) [@CESAR\_MURILO\_DA\_SILV](https://forums.percona.com/u/CESAR_MURILO_DA_SILV)\
**Post date:** [November 25, 2019, 1:14pm UTC](https://forums.percona.com/t/how-do-i-run-optimize-with-pt-online-schema-change/7284/2 "2019-11-25T13:14:00Z")

</div>

The manual says:

“In almost all cases a PRIMARY KEY or UNIQUE INDEX needs to be present in the table. This is necessary because the tool creates a DELETE trigger to keep the new table updated while the process is running.”
