Hi mtrinath,
Focusing on why the ibdata file never shrinks in size... absolutely, I can explain why the ibdata file never shrinks in size. The ibdata file continuously grows without ever shrinking, and that's per design (by Sun/Oracle, not CA). For a different point of view though, according to this report for a feature request to maintain the sizing of an ibdata file in MySQL, some people view this as a lack of resizing functionality that should be implemented or improved upon in a future version. However, that looks unlikely to change anytime soon, as that report / feature request is over 12 years old now, and still needing to be triaged.
The blunt fact of the matter is this: the ibdata file always will grow in size, never shrink in size, at least in terms of disk space usage. However, if you purged a bunch of information from the database stored in the ibdata file, you will find that new data being added won't expand the size of the ibdata file until it fills out to the size the ibdata file left off at before it continues to grow again. For example: Let's say you have an ibdata file at 5 GB in size on your hard disk, and you then purge 1 GB worth of data from the database written inside the ibdata file. That means that the ibdata file now stores just 4 GB of data, however it still takes up 5 GB of disk space (because remember, it never shrinks per design), and thus has an extra 1 GB now that it can contain before the ibdata file grows any further past the 5 GB in size it was sitting at. So in other words, if you remove data (i.e. via the audit_purge.sh script), it will stop the ibdata file from growing temporarily as it frees up space inside of the ibdata file, even though that is not reflected in actual disk space consumption.
If you run the command in this very same community thread, both before and after the audit_purge.sh script, you should see a difference in sizing of the ssg database. Again for quick reference though, below is the command to run to find the actual size of the ssg database itself:
mysql -e 'select table_name, round(((data_length + index_length) / (1024*1024)),2) as "size in megs" from information_schema.tables where table_schema = "ssg";'
If the ibdata file size gets out of hand and starts to consume all your available disk space in the volume / partition, or there is a large difference between the output of the command above and the actual size of the ibdata file, then the solution is to 1) take a full MySQL dump, 2) remove the ibdata file from the disk, then 3) import the backup into MySQL again where it will create a new ibdata file at just the size of the database itself to begin with, which helps save all the space that was wasted over time during periods of peak activity where it might shoot the ibdata file size quite high before the purge script runs, for example. We actually have a KB article (must be signed in to the Layer 7 Support Portal to view it though) with detailed instructions on how to shrink the ibdata file. I had also in this very same community thread to shrink the ibdata file.
This is ultimately an odd quirk in the design of the ibdata storage engine within MySQL, outside the control of CA Technologies. For performance reasons, we had chosen to go with the ibdata storage engine. That is always subject to change in the future if we find a much more efficient storage engine that we believe will improve the CA API Management product suite MySQL databases. But until such time, the ibdata storage engine is the better one we find for our products, and that is why we provide the necessary tools and instructions to keeping the file size to a minimum as we are aware of the quirk in the innodb storage engine design in MySQL.
I hope the above answers your question on why the ibdata file does not shrink and what can be done about it.
Sincerely,
Dustin Dauncey
Support Engineer, Global Customer Success
Email: API-Support@ca.com
Phone: +1 800 225 5224
Outside of North America - ca.com/us/worldwide.aspx
CA API Management Community: ca.com/talkapi