# Running pt-online-schema-change increases the size of the file on disk

**URL:** <https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939>\
**Category:** Percona XtraDB Cluster 5.x\
**Created:** [November 10, 2021, 1:41pm UTC](https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939 "2021-11-10T13:41:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravimalghan](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@ravimalghan](https://forums.percona.com/u/ravimalghan)\
**Post date:** [November 10, 2021, 1:41pm UTC](https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939/1 "2021-11-10T13:41:45Z")

</div>

I have been using pt-online-schema-change to reduce the file size on disk for a table that has lot of deletes. It has worked as expected for a long time. I have not updated anything. For my last 4 runs, the file size seems to be growing everytime I run. The number of rows is about the same. I started with 141G. Ran the pt-online-schema-change about 4 times. When I just ran it now, the file size on disk went from 191G to 200G. All the runs are completing successfully (triggers dopped, the \_\<table\_name\> dropped). Why would this be happening?

> pt-online-schema-change --version  
> pt-online-schema-change 3.0.12

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [November 11, 2021, 3:01am UTC](https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939/2 "2021-11-11T03:01:50Z")

</div>

Can you give us more information? How are you running pt-osc? Have you confirmed free space before running and after running? Are you watching the size of the shadow table as it is being populated?

---

<div class="post-metadata">

**Author:** ![ravimalghan](https://avatars.discourse-cdn.com/v4/letter/r/c4cdca/32.png) [@ravimalghan](https://forums.percona.com/u/ravimalghan)\
**Post date:** [February 25, 2022, 2:30pm UTC](https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939/3 "2022-02-25T14:30:37Z")

</div>

Here’s how I am running the command.

File size before I ran the command

```auto
cd /export/apps/moogdata/var; find ./ -type f -exec du -Sh {} + | sort -rh | head -n 20
160G	./lib/mysql/historic_moogdb/snapshots.ibd

```

```auto
pt-online-schema-change --chunk-size 20000 --user=root --ask-pass --progress time,10 --socket=/export/apps/moogdata/var/lib/mysql/mysql.sock --print --nocheck-unique-key-change --no-check-alter --execute --critical-load Threads_running=100 --alter "ENGINE=InnoDB" h=localhost,D=historic_moogdb,t=snapshots

```

It completes successfully

```auto
Copying `historic_moogdb`.`snapshots`: 99% 00:13 remain
Copying `historic_moogdb`.`snapshots`: 99% 00:05 remain
2022-02-25T09:12:20 Copied rows OK.
2022-02-25T09:12:20 Analyzing new table...
2022-02-25T09:12:20 Swapping tables...
RENAME TABLE `historic_moogdb`.`snapshots` TO `historic_moogdb`.`_snapshots_old`, `historic_moogdb`.`_snapshots_new` TO `historic_moogdb`.`snapshots`
2022-02-25T09:12:20 Swapped original and new tables OK.
2022-02-25T09:12:20 Dropping old table...
DROP TABLE IF EXISTS `historic_moogdb`.`_snapshots_old`
2022-02-25T09:13:00 Dropped old table `historic_moogdb`.`_snapshots_old` OK.
2022-02-25T09:13:00 Dropping triggers...
DROP TRIGGER IF EXISTS `historic_moogdb`.`pt_osc_historic_moogdb_snapshots_del`
DROP TRIGGER IF EXISTS `historic_moogdb`.`pt_osc_historic_moogdb_snapshots_upd`
DROP TRIGGER IF EXISTS `historic_moogdb`.`pt_osc_historic_moogdb_snapshots_ins`
2022-02-25T09:13:00 Dropped triggers OK.
Successfully altered `historic_moogdb`.`snapshots`.

```

File size went to 240G

```auto
cd /export/apps/moogdata/var; find ./ -type f -exec du -Sh {} + | sort -rh | head -n 20
240G	./lib/mysql/historic_moogdb/snapshots.ibd

```

---

<div class="post-metadata">

**Author:** ![matthewb](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/matthewb/32/34_2.png) [@matthewb](https://forums.percona.com/u/matthewb)\
**Post date:** [February 25, 2022, 4:33pm UTC](https://forums.percona.com/t/running-pt-online-schema-change-increases-the-size-of-the-file-on-disk/12939/4 "2022-02-25T16:33:06Z")

</div>

I would use the innodb\_ruby tools to count the number of data, index, and free pages before and after. Because this is row-by-row copying, the new table may be attempting to balance the pages to favor more intra-page free space for new INSERTs rather than make pages as compact as can be. Generally InnoDB will fill data pages only to 50 percent initially. This results in a naturally larger disk footprint. Maybe check out this parameter [MySQL :: MySQL 5.7 Reference Manual :: 14.15 InnoDB Startup Options and System Variables](https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_fill_factor)
