Lesson 28 of the SQL Optimization Course: The Impact of Index Quantity on MySQL Write Performance

For relational databases, the design of tables and SQL is written are particularly crucial. It wouldn’t be an exaggeration to say that they account for 90% of performance. So this time, specifically targeting these two major knowledge areas, we’ll conduct a detailed analysis for you, peeling back the layers.
This Series uses plain and understandable language and selects a large number of examples to elaborate on the subtleties for you.
🧑💻 Target audience:
We will use MySQL as the demonstration database.
This study examines how increasing index counts affect write operations (INSERT/UPDATE/DELETE) in MySQL. A controlled environment was established using a sandbox instance (3500 port) with 10 identically structured tables (t1
to t10
). Each table had 11 fields (id
+ r0
to r10
), but varied in secondary index quantity (t1=1 index, t10=10 indexes).
Table Schema:
|
|
Inserting 100,000 rows into tables with varying index counts:
|
|
Observation: Each additional index increased insertion time by ~10-20%.
Updating 100,000 rows across all indexes:
|
|
Impact: Index updates became exponentially slower (t10 was ~12x slower than t1).
Deleting 100,000 rows (highlighting redo log overhead):
|
|
Key Insight: DELETE triggers page splits and purging, amplified by index fragmentation.
Importing 100,000 rows with indexes:
|
|
Result: Index maintenance added ~4x overhead to bulk imports.
TRUNCATE
instead of DELETE
for mass deletions.Future Work: Explore InnoDB adaptive hashing and partitioning strategies for high-write environments.
👋 See you in the next lesson.
SQLFlash is your AI-powered SQL Optimization Partner.
Based on AI models, we accurately identify SQL performance bottlenecks and optimize query performance, freeing you from the cumbersome SQL tuning process so you can fully focus on developing and implementing business logic.
Join us and experience the power of SQLFlash today!.