Reduce DB size by truncating table - jigneshpshah/greycube_helpmanual GitHub Wiki

To empty tabEmail Queue and reduce db size, table size and on disk file size.

check sizes of all dbs on server

SELECT table_schema AS "Database", 
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" 
FROM information_schema.TABLES 
GROUP BY table_schema 
order by "Size (MB)" desc

check table size of a db

SELECT table_schema as `DB`, table_name AS `Table`, 
  ROUND(((data_length + index_length) / 1024 / 1024), 2) `Size (MB)` 
  FROM information_schema.TABLES 
  where table_schema = 'hotel13'
  ORDER BY (data_length + index_length) DESC;

OR if Database name is not known


SELECT table_schema AS DB_NAME, TABLE_NAME, ROUND((DATA_LENGTH+INDEX_LENGTH)/1024/1024,2) AS TABLE_SIZE_in_MB 
FROM information_schema.TABLES
where TABLE_SCHEMA <> 'information_schema' -- and table_schema = ''
Order By TABLE_SIZE_in_MB desc

truncate and optimize, which ever table to empty

truncate table `tabEmail Queue` ;
truncate table `tabEmail Queue Recipient` ;
truncate table `tabDeleted Document`;

alter table `tabEmail Queue` Engine=InnoDB; 
alter table `tabEmail Queue Recipient` Engine=InnoDB;
alter table `tabDeleted Document` Engine=InnoDB;

check on disk db file size

cd /var/lib/mysql
du -sh *
⚠️ **GitHub.com Fallback** ⚠️