473,385 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

help needed - trimming InnoDB database size

I'm using InnoDB with Mysql and I've used delete to delete over 10
million records, but the InnoDB database is still the same size on the
disk (over 100 gigs) is there a way to get Mysql/InnoDB to shrink or
trim this size?

and also, can I set a maximum size and make it so itll rotate itself,
as in purge out old entries as new ones come in when it hits the
maximum?

I'm not used to InnoDBs... so I could use some help with this...

the database is using about 95% of my drive, so its a real problem...
Jul 20 '05 #1
1 3544
Beyonder wrote:
I'm using InnoDB with Mysql and I've used delete to delete over 10
million records, but the InnoDB database is still the same size on the
disk (over 100 gigs) is there a way to get Mysql/InnoDB to shrink or
trim this size?
I don't know specificaly about InnoDB, but I've used other RDBMS that do
not shrink the database when you delete, they just re-use the available
space the next time you add more records.

The reason is that it's hard to guarantee that the records you deleted
would be contiguous, and if it tried to shrink the file following a
delete, it'd have to move the remaining records around to try to
"defrag" the database file. This can be a time-consuming operation, and
it would make the DELETE statement take many minutes to complete, if it
operated on a very large file like yours.

Anyway, one solution I have seen is often to back up and restore the
database. But this is hard to do if you have limited disk space.

You can also do this for just one table. For example, you could do this
(assuming the table you just reduced is called "MyTable"):

ALTER TABLE MyTable RENAME TO MyTable_purgeme
CREATE TABLE MyTable (
...column defs identical to original table...
) AS SELECT * FROM MyTable_purgeme;
...do some tests to verify that it copied correctly...
DROP TABLE MyTable_purgeme;

I'm assuming the remaining rows you want to keep after the DELETE are
more than zero, but few enough to fit an additional copy in the
remaining space on your hard drive. If you have deleted _all_ rows from
the table, I suggest just dropping the table and re-creating it.
and also, can I set a maximum size and make it so itll rotate itself,
as in purge out old entries as new ones come in when it hits the
maximum?


I don't know of any such feature for data tables, only logs.

But I imagine one problem with such a feature would be: how does one
define "old entries"? They could be those with lower-value primary
keys, or records with earlier values in a DATE field, or some other
criterion. It's best to purge old entries based on your application
logic.

If you did this operation on a regular schedule, it might delete a more
modest portion of the table, and then further database activity would
reclaim the empty space, eliminating the need for the data-swap I
described above.

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Andy | last post by:
I'm using Mysql Max-4.1.4-gamma for Linux. I have a question related to a problem with my database server. If on my db server I have 2 different database, say DB1 & DB2, I create two INNODB tables...
0
by: Rajesh Kapur | last post by:
I have a master slave configuration on linux machines running MySQL 4.0.21. Once every hour, a process deletes about 9000 rows and re-inserts fresh data on the master. The master process completes...
3
by: siliconmike | last post by:
We have developed a site where users can post blogs. Now, each blog is stored in a separate row, in a table called blog_table. This single table would be the most active one and would grow to...
4
by: gamma_one | last post by:
I have an INNODB installation that has caused me some problems recently with the data files growing beyond the UNIX file size limits. I have everything back to normal but, My question: is there...
4
by: Good Man | last post by:
Hi there I have a database with about 20 or so tables, maybe a few thousand rows in each. I am starting to do more complex things with my insertions etc, and I want to start to use...
1
by: fuzzybr80 | last post by:
Hi, I am using MySQL version 5.0 on Linux Fedora Core 4. I recently got this error message: 060609 11:06:29 InnoDB: ERROR: the age of the last checkpoint is 9433557, InnoDB: which exceeds...
0
by: shakahshakah | last post by:
Just started investigating InnoDB after having used MyISAM tables in the 4.0.12 version, almost immediately ran into a locking issue with INSERTs, DELETEs, and transactions. Given the following...
3
by: Marty | last post by:
OK, I'm new at all of this and have decided to take on a project to learn. We have a fishing club that has 23 members. Each weak we go fishing in various places for 4 hours. Not together, usually 2...
5
by: odntuk | last post by:
Hello, I'm new to database development and need your help. Although, I'm new I know that storing multiple entries into a database field is a horrible idea. Therefore, I'm trying to implement...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.