# About optimize table

**URL:** <https://forums.percona.com/t/about-optimize-table/1455>\
**Category:** Other MySQL® Questions\
**Created:** [July 22, 2010, 9:05am UTC](https://forums.percona.com/t/about-optimize-table/1455 "2010-07-22T09:05:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gjuan](https://avatars.discourse-cdn.com/v4/letter/g/53a042/32.png) [@gjuan](https://forums.percona.com/u/gjuan)\
**Post date:** [July 22, 2010, 9:05am UTC](https://forums.percona.com/t/about-optimize-table/1455/1 "2010-07-22T09:05:59Z")

</div>

Hi,

I know how to use the optimize command for a table but when it is executing, why it creates a temp table?

if i have a table with 50000000 or rows, it is a good practice to use it?

using alter table, can i rebuild a table and update table statistics? How can i use it?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![gmouse](https://avatars.discourse-cdn.com/v4/letter/g/b9e5f3/32.png) [@gmouse](https://forums.percona.com/u/gmouse)\
**Post date:** [July 22, 2010, 1:37pm UTC](https://forums.percona.com/t/about-optimize-table/1455/2 "2010-07-22T13:37:09Z")

</div>

[URL][http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html[/URL]](http://dev.mysql.com/doc/refman/5.1/en/optimize-table.html%5B/URL%5D)

For InnoDB tables, OPTIMIZE TABLE is mapped to ALTER TABLE, which rebuilds the table to update index statistics and free unused space in the clustered index.

Index statistics can be updated with analyze table also.
