Sunday, January 20, 2008

MySQL InnoDB tablespace reclamation

Been having "table is full" and disk full errors again, so I decided to prune the data.

The usual steps were taken, following the procedures in this site: http://www.saturn.in/gpl/mysql.html

But before following those steps, ...
1. I made sure my latest backup of the main database was complete.
a. copied bill_settings, datafile_settings, and system_settings tables to my own database.
2. I dropped the main database.
3. Followed the instructions mentioned above.
4. Restored the 3 copied tables from my database because they're essential to the restore utility program.
5. Used "restore utility.exe" program to restore the tables.

For this housecleaning instance, I also used "remove zero from artran" program to transfer the fully-paid bills to the artran history table (this took more than 3 hours!!!). While doing this, I made a temporary database on the other server and uploaded last night's backup of artran and artran_vat. I created a table from the still unpaid bills (select account_no_id,applytodocno,sum(docamt) amount,docdate from artran group by account_no_id,applytodocno having amount <> 0.00).

Then I "inner joined" the resulting table to artran_vat and selected matching vat data into an outfile. I'm curious, though, why artran_vat shrunk from 476MB to 5.5MB (??!!). Only 61898 records?!?! With an average of 5 VAT charges per bill, those are only about 12,000 bills unpaid! What the ?!?!

Anyway, I'm rechecking now.

Found the problem. Looks like either a file system or a MyISAM limit was hit when I uploaded the latest artran_vat data to the new server.

Now, from an erroneous 5.5MB outfile, I have a 17MB one. And this time I'm sure the data is complete. Heh.

Addendum: Need to erase the BINLOGs after uploading the data.