472,353 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 3471
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...
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...
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...
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...
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...
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...
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,...
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...
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.