Sure, we have such a script. It does the following:
- checks the actual fragmentation (various) status of the tables and its indices
- it also handles partitionsos , that it only reorgs the partition required
- given input parameters, one per each derived status, if these are exceeded, it writes a reorg_<type> <table> <index> <partition> script for either the table/index/partition (without doubling up)
- designed for minimising teh maintenance window
- with a generic script name (useful for a standing crontab entry) or specific name
- alloing for parallel execution (one script is split into eg. 8 balanced scripts) on eg. 8 engines
- optionally executes the script
- also reports on the various fragmentation statuses without producing a script (useful for watching growth, fragmentation and capacity planning).
We have a similar script for update statistics (again table/index/partition/column). This requires a small structure in the db to keep track of the growth/change of each column, which it uses as the basis for deciding that stats need to updated. High performance, no repetition, minimised execution time.
Both are highly configurable and commercial. If you are interested send us an email.
Otherwise, I am happy to remain here and answer questions.