Skip to content

Instantly share code, notes, and snippets.

@sawantuday
Created April 25, 2016 16:16
Show Gist options
  • Select an option

  • Save sawantuday/4c6f0c39fb66f5a65bc03085f9d60732 to your computer and use it in GitHub Desktop.

Select an option

Save sawantuday/4c6f0c39fb66f5a65bc03085f9d60732 to your computer and use it in GitHub Desktop.
Reclaim unused space from large partitioned MySQL tables.
create table tempUrls like urls;
insert into tempUrls;
select * from urls where id < 100;
delete from urls where id < 100 limit 50;
alter table urls REBUILD PARTITION p000;
alter table urls ANALYZE PARTITION p000;
insert ignore into urls select * from tempUrls;
drop table tempUrls;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment