# Notebook 3: one lookup in 1,000,000 rows, without and with an index # run at: 2026-11-30 19:18 UTC # runner: Linux-7.0.0-1020-azure-x86_64-with-glibc2.43 | 2 vCPU # PostgreSQL: 18.7 (Debian 18.7-1.pgdg13+5) # MySQL: 8.4.13 # MongoDB: 8.0.38 ## PostgreSQL 18 table size: 150 MB | 19231 pages of 8 KB -- no index on username (parallel query off, to show one plain scan) Seq Scan on nb_users (actual time=33.087..63.076 rows=1.00 loops=1) Filter: (username = 'user500000'::text) Rows Removed by Filter: 999999 Buffers: shared hit=14364 read=4867 written=38 Planning: Buffers: shared hit=25 read=1 Planning Time: 0.083 ms Execution Time: 63.087 ms -- after CREATE INDEX nb_users_username ON nb_users (username) Index Scan using nb_users_username on nb_users (actual time=0.027..0.028 rows=1.00 loops=1) Index Cond: (username = 'user500000'::text) Index Searches: 1 Buffers: shared hit=1 read=3 Planning: Buffers: shared hit=16 read=1 Planning Time: 0.163 ms Execution Time: 0.040 ms ## MySQL 8.4 -- no index on username -> Filter: (nb_users.username = 'user500000') (cost=104420 rows=99129) (actual time=526..666 rows=1 loops=1) -> Table scan on nb_users (cost=104420 rows=991288) (actual time=0.474..596 rows=1e+6 loops=1) Handler_read_rnd_next (rows read in a scan): 1000001 | Handler_read_key (index lookups): 1 | Handler_read_next: 0 -- after CREATE INDEX nb_users_username ON nb_users (username) -> Index lookup on nb_users using nb_users_username (username='user500000') (cost=0.649 rows=1) (actual time=0.229..0.23 rows=1 loops=1) Handler_read_rnd_next (rows read in a scan): 0 | Handler_read_key (index lookups): 1 | Handler_read_next: 1 ## MongoDB 8.0 -- no index on username plan: COLLSCAN nReturned: 1 | totalKeysExamined: 0 | totalDocsExamined: 1000000 | executionTimeMillis: 342 -- after createIndex({username: 1}) plan: FETCH <- IXSCAN nReturned: 1 | totalKeysExamined: 1 | totalDocsExamined: 1 | executionTimeMillis: 0