Skip to content

reIndex tool - #193

Open
satebam wants to merge 7 commits into
awslabs:masterfrom
satebam:reIndex-tool
Open

reIndex tool#193
satebam wants to merge 7 commits into
awslabs:masterfrom
satebam:reIndex-tool

Conversation

@satebam

@satebam satebam commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:

This tool helps to script out the reindex commands for the collections which are highly fragmented from the update/deletes to the Amazon DocumentDB.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

satebam added 4 commits July 14, 2026 14:33
Added documentation for the DocumentDB-Reindex tool, including requirements, installation instructions, usage, and example commands.
Updated README.md to enhance clarity and correct typos.

@tmcallaghan tmcallaghan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes requested.

Comment thread operations/reIndex-tool/README.md
Comment thread operations/reIndex-tool/README.md Outdated
Comment thread operations/reIndex-tool/README.md Outdated
Comment thread operations/reIndex-tool/README.md Outdated
Comment thread operations/reIndex-tool/README.md Outdated
Comment thread operations/reIndex-tool/reIndex-script.py
Comment thread operations/reIndex-tool/reIndex-script.py Outdated
Comment thread operations/reIndex-tool/reIndex-script.py
Comment thread operations/reIndex-tool/reIndex-script.py
Comment thread operations/reIndex-tool/reIndex-script.py Outdated
@@ -0,0 +1,47 @@
# DocumentDB-Reindex

In Amazon DocumentDB, high-write workloads cause index fragmentation (bloat) over time. Reindexing removes this bloat and reclaims storage. This tool identifies highly bloated indexes and provides the reindex commands to remove the bloat.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to remove mixed case of this tools directory, "reIndex-tool" should be "reindex-tool".

@@ -0,0 +1,186 @@
import argparse

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove mixed case, should be "reindex-script.py", not "reIndex-script.py".

--region AWS region for Secrets Manager. Defaults to us-east-1
--unusedCollectionSizePercent Unused collection size percentage. Defaults to 30
--workers Number of workers for reindex operation. Defaults to 2
--tls-ca-file Path to CA file for TLS connections (e.g., global-bundle.pem)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, if using TLS the CA file should be supplied via the URI.

else:
appConfig['connectionString'] = args.uri

# Append TLS CA file to URI if provided

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this argument and this code.

else:
collStats = client[thisDb['name']].command("collStats", thisColl['name'])
# Check if collection bloat exceeds the threshold
if 'unusedStorageSize' in collStats and collStats['unusedStorageSize']['unusedPercent'] >= int(appConfig['unusedCollectionSizePercent']):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the code making the reindex decision based on the collection's unused size (percent) and not simply the bloat of each individual index?

@tmcallaghan tmcallaghan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants