Quick revision
The short answer
I would make index cost visible to the teams that own it, with a regular per-service report of index size, write overhead, scans and estimated monthly cost. Teams keep ownership of their indexes through their migrations, while the platform provides the tooling: a safe removal process that observes unused indexes for a full business cycle, keeps the DDL to recreate them and drops them concurrently, never touching unique or constraint indexes automatically. New indexes on large or hot tables get a light review, and we measure the outcome in cost and write latency.
What to remember
In this answer, we built an organisation-wide approach to index cost. We made cost visible with regular per-service reports of index size, scans and estimated monthly cost including replicas, backups and WAL archives. Teams own their indexes through their migrations while the platform provides tooling. Safe removal observes candidates for a full business cycle, keeps the DDL to recreate them, drops them concurrently and never automatically removes unique or constraint indexes. A light review covers new indexes on large or hot tables, and we measure the result in cost and write latency.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would make index cost visible to the teams that own it, with a regular per-service report of index size, write overhead, scans and estimated monthly cost. Teams keep ownership of their indexes through their migrations, while the platform provides the tooling: a safe removal process that observes unused indexes for a full business cycle, keeps the DDL to recreate them and drops them concurrently, never touching unique or constraint indexes automatically. New indexes on large or hot tables get a light review, and we measure the outcome in cost and write latency.
Why this question is asked
Unused indexes are pure cost: they slow every write, take disk and memory, and are copied into replicas, backups and WAL archives, while giving nothing back. When a third of index space across 400 databases is unused, there is real money to save. But a central team that starts dropping indexes will break something on the first quarter-end, and a heavy approval process slows every team. Interviewers ask this leadership question to see whether we can design a program that changes behaviour across many teams without becoming a bottleneck. In this answer, we will look at why the cost is invisible today, make it visible, set ownership, automate safe removal, add a light gate for new indexes, and measure the outcome.
1Why Index Cost Is Invisible Today
When a developer adds an index, the benefit is visible at once: an endpoint gets faster and a ticket closes. The cost is spread thin: a little more write latency on every insert, a little more WAL, a few more gigabytes on the primary, the replicas and the backups. Nobody sees a bill for it. Over years, indexes added for features that no longer exist stay forever, because removing one carries a small risk and no visible reward.
So the program must change the information people have, not just add rules. Teams already make reasonable decisions with what they can see.
2Making Cost Visible
The platform team collects, for every database, each index's size from pg_relation_size, its scan count from pg_stat_user_indexes (or performance_schema in MySQL), and the write rate of its table. It turns size into an estimated monthly cost, multiplied by the real number of copies: primary, replicas, backup retention and WAL archive. A 100 GB index on a primary with two replicas and 30 days of backups costs far more than 100 GB of disk.
Each owning team gets a report every month or quarter listing their indexes with zero or very few scans, their size and their estimated cost. Seeing 'these 14 indexes cost about 3,000 a month and have not been used in 90 days' is usually enough for a team to act.
Notice that scan counters are per server and reset with statistics resets. An index unused on the primary may be used by reports on a replica, so the collector must combine counters from all replicas and record when they were last reset.
3Setting Ownership
Indexes are part of a service's schema, so they belong to the team that owns the service and change only through that team's migrations. The platform team does not drop indexes on its own decision. It provides the data, the tooling and the defaults, and the team decides. This keeps the database schema consistent with the migration history and keeps the knowledge of 'why this index exists' with the people who have it.
4Automating Safe Removal
The removal process does the careful parts automatically. A candidate is an index with no scans across all servers. The tool marks it, and then waits for a full business cycle, usually at least a month and including the month-end and quarter-end jobs, before proposing removal. It saves the exact CREATE INDEX statement, so recreating it later is a one-command change. The team approves, and the tool drops it with DROP INDEX CONCURRENTLY in PostgreSQL, which does not block writes, as a normal migration.
Some indexes are never automatic candidates: unique indexes and those backing primary key, unique or exclusion constraints, because they enforce correctness even if no query scans them. Foreign key supporting indexes need care too, since they make parent deletes fast even when their scan count is low. In MySQL 8, an index can first be made invisible, ALTER TABLE ... ALTER INDEX ... INVISIBLE, so the optimizer ignores it while it is still maintained, which gives an instant undo.
- Collect scans from primary and replicaswith reset times
- Unique, constraint or FK-supporting?YesExclude from automatic removalNoMark as candidate
- Observe a full business cycleinclude month-end and quarter-end
- Still unused?YesPropose removal to owning teamNoClear the mark
- Save the CREATE INDEX DDLrecreate in one step if needed
- Drop concurrently in a migrationwatch latency for a week
6 steps in order. Play them, or step through them one at a time.
5A Light Gate for New Indexes
To slow the growth, new indexes on large or hot tables, say above 100 GB or above 1,000 writes per second, need a short justification in the migration review: the query it serves, its plan before and after, and the expected write cost. Small tables need nothing. This is a quick check by a peer or a database-minded reviewer, not a committee, and it often leads to a better index, such as extending an existing one instead of adding a new one.
6Measuring the Outcome
We track the result in the terms that started the program: storage and IOPS cost per month, total index size, write latency on the busiest tables, WAL volume and replica lag. We report savings including replicas, backups and WAL archives, because that is where much of the cost is. If teams see their own numbers improving, the program sustains itself.
7Follow-up questions
How do you handle indexes used only by quarterly jobs?
The observation window must cover the jobs' cycle, so an index used once a quarter shows at least one scan before anyone proposes dropping it. For indexes that serve only a rare batch job, there is a second option: create the index just before the job and drop it afterwards, or run the job on a replica or in an analytics store where its index costs nothing on the primary. The team decides based on how long the build takes compared with how often the job runs.
What if a team ignores the report?
Then we look at why. Sometimes the team lacks time, and the tooling that prepares the migration for them solves it. Sometimes the index is needed for reasons the counters do not show, which we record. If a service keeps very expensive unused indexes for no reason, the cost report goes to the owning manager as part of the normal cost review, the same way other infrastructure costs do.
8Conclusion
In this answer, we built an organisation-wide approach to index cost. We made cost visible with regular per-service reports of index size, scans and estimated monthly cost including replicas, backups and WAL archives. Teams own their indexes through their migrations while the platform provides tooling. Safe removal observes candidates for a full business cycle, keeps the DDL to recreate them, drops them concurrently and never automatically removes unique or constraint indexes. A light review covers new indexes on large or hot tables, and we measure the result in cost and write latency.
Open with
I would start by making the cost visible, because today the benefit of an index is visible to the team that adds it and the cost is invisible.
Then, if they want more
The platform would collect every index's size, its scan counts from the primary and all replicas, and the write rate of its table, and turn that into an estimated monthly cost that includes replicas, backups and WAL archive, since those multiply the real cost. Each owning team gets a regular report of indexes with no scans and what they cost.
Ownership stays with the teams: indexes are part of the service's schema and change only through its migrations. The platform provides tooling that does the careful parts: it marks candidates, waits a full business cycle including quarter-end, saves the exact DDL so recreating is one step, and then drops concurrently through a migration the team approves.
It never proposes unique or constraint-backing indexes automatically, and it treats foreign key indexes with care. In MySQL I would make an index invisible first, which gives an instant undo. For growth, a light review for new indexes on large or hot tables, with the query and plan as evidence.
And I would report the outcome in storage and IOPS cost and write latency, so teams see the result of their work.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- MySQL 8
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Across 400 databases, storage and IOPS costs grew 35 percent last year, and analysis...": https://scrivio-interview-library.netlify.app/databases/indexing/ad729416f1/