Index Visualizer
The same query — db.users.find({ age: 50 }) — executed two ways over 64 documents. Watch the collection scan grind through everything while the B-tree walks straight to the answer.
Without index — COLLSCAN
O(n)45
34
18
34
50
50
34
18
50
18
50
18
34
34
50
50
50
18
34
18
34
50
34
34
50
50
50
50
50
34
50
50
18
18
50
34
18
59
50
50
18
34
18
34
34
34
18
50
50
18
18
42
18
42
50
34
50
50
34
18
50
50
18
18
- Docs examined
- 0
- Returned
- …
- Est. time
- …
With index — IXSCAN (B-tree)
O(log n)root
[18 | 34]
internal 0
[18 | 18 | 18 | 34]
internal 1
[34 | 50 | 50 | 50]
18–18
18–18
18–34
34–34
34–50
50–50
50–50
50–59
- Keys examined
- 0
- Returned
- …
- Est. time
- …
What you're seeing
The collection scan must examine all 64 documents no matter what. The B-tree walks root → internal node → leaf — three hops — then reads only the matching entries. At 64 documents the difference is milliseconds; at 64 million it is the difference between 0.5ms and a 30-second table-melting scan. Create indexes with db.users.createIndex({ age: 1 }) and verify with .explain().