Part 42: Bulk Inserting Multiple Rows Efficiently
Executing 10,000 individual INSERT statements creates massive network round-trip latency.
1. Multi-Row Values Syntax
INSERT INTO categories (name, description) VALUES
('Electronics', 'Gadgets and hardware'),
('Books', 'Physical and electronic books'),
('Home', 'Furniture and decor');
2. Performance Comparison
- 1,000 single-row inserts: ~4.5 seconds.
- 1 bulk insert of 1,000 rows: ~0.08 seconds (50x faster!).
Key Takeaways
- Batch inserts into multi-row statements (batches of 500–1,000 rows) for optimal throughput.
In Part 43, we explore Inserting Data from Other Tables: INSERT INTO ... SELECT!

