473,725 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3566
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
2290
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 with the same name (foo), one for each database, how they are stored in the innodb data dictionary ? DB1.foo & DB2.foo or simply foo ? Thank you in advance Andrea
0
2486
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 processing under a minute. The updates arrive on the slave within seconds. However, the slave takes about 15-20 minutes to post the same updates. Both master and slave have InnoDB tables. The master and the slave are almost identical in capacity...
3
2722
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 large size in the coming years. What is the most advisable engine for this table - Innodb or MyISAM ?
4
1430
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 a mysql systems table or variable that I can get the: -Current space allocated? -Current space used?
4
2948
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 transactions, so I imagine I should change some table types in the database from MyISAM to InnoDB. I know that InnoDB tables are a completely different beast than MyISAM in terms of data storage etc... ie: instead of using folders on the server, everything...
1
40717
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 the log group capacity 9433498. InnoDB: If you are using big BLOB or TEXT rows, you must set the
0
2306
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 table: CREATE TABLE test1 ( f1 varchar(32) default NULL ) and a steady stream of INSERTs from a command-line shell:
3
1432
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 to a boat and it's your choice where to go. I want to build a database / website that the individual fishermen can go to and log there success. The fishermen can enter the fish type, size, weight, date caught. I only want them to add, edit, and...
5
3873
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 cross-reference/look-up tables. Here's the problem I'm trying to solve... I'm working on a restaurant guide site with restaurants having multiple dishes and dishes possibly being assigned to multiple restaurants.
0
8888
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9111
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4517
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.