| |||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | #1 (permalink) |
| NamePros Regular | Interesting mySQL backup problem . . . I am backing up several tables via a PHP script. The script lists the tables, you click on one, then click "backup table" and the table is backed up (the new table name is the old table name appended with the date of the backup, so table 'orders' would become 'orders_043007'). The problem is the size of the backed up table. They always end up being 6x larger than the original table. I backed up one table last night that had a size of 31.8 MB and the backup was 197.4 MB, according to the data in phpMyAdmin. The SQL I am using to do the backup is: PHP Code: PHP Code:
__________________ The mass purge has begun. |
| |
| | #2 (permalink) |
| NamePros Member | A few questions that may get you thinking about the solution: 1. Was the original data created using a different version of MySQL than you are using now? The way certain things are stored changed over the past few MySQL updates. For example, namepros member DanR can tell you that DECIMAL changed the way it works as of MySQL 5.0.3! http://www.namepros.com/programming/...-pay-25-a.html 2. Why are you altering the new table's primary key type? If you look at http://dev.mysql.com/doc/refman/5.0/...ric-types.html , you'll see that BIGINT requires 8 bytes, where INT only requires 4. MEDIUMINT requires 3, SMALLINT requires 2, and TINYINT only 1! 3. Have you tried using ANALYZE TABLE? This is a dead giveaway if PHPMyAdmin is saying that the cardinality of your indexes is "none". See if that helps. Other than that, it may be helpful if you most the structures of your old and new tables here. Use PHPMyAdmin to dump the structure of both tables and post it here... |
| |
| | #3 (permalink) | |
| NamePros Regular | The backup is on the same server, the same mysql version. Basically, once per week, I just go in and backup the existing table to the same database, with the date appended. Same server, same version, same everything. The reason I alter the table's primary keys is because I noticed that when I did the SQL: Code: $sql = "CREATE TABLE $newTable AS SELECT * FROM $_POST[buTable]"; Lastly, you suggest that I run an "analyze" on the table. I did that and the message I receive back was that the status was "OK". And, the cardinality is set (i.e. it does not say "none"). Ugh . . . -Bob Quote:
__________________ The mass purge has begun. | |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |