explain.depesz.com

PostgreSQL's explain analyze made readable

Result: TcEk : SELECT purchase.id FROM purchase WHERE user_id IN (SELECT id FROM user1 WHERE account_id IN (SELECT generate_series(1,1000)))

Settings
# exclusive inclusive rows x rows loops node
1. 60,193.191 378,551.797 ↑ 15,277.5 2,000 1

Hash Semi Join (cost=411,895.02..4,350,413.77 rows=30,554,912 width=4) (actual time=282,982.538..378,551.797 rows=2,000 loops=1)

  • Hash Cond: (purchase.user_id = user1.id)
2. 318,352.639 318,352.639 ↑ 1.0 100,000,000 1

Seq Scan on purchase (cost=0.00..1,540,541.00 rows=100,000,000 width=8) (actual time=0.023..318,352.639 rows=100,000,000 loops=1)

3. 1.075 5.967 ↑ 25,000.0 1,000 1

Hash (cost=1,738.02..1,738.02 rows=25,000,000 width=4) (actual time=5.967..5.967 rows=1,000 loops=1)

  • Buckets: 2,097,152 Batches: 32 Memory Usage: 16,386kB
4. 1.048 4.892 ↑ 25,000.0 1,000 1

Nested Loop (cost=18.08..1,738.02 rows=25,000,000 width=4) (actual time=0.628..4.892 rows=1,000 loops=1)

5. 0.671 0.844 ↓ 5.0 1,000 1

HashAggregate (cost=17.52..19.52 rows=200 width=4) (actual time=0.590..0.844 rows=1,000 loops=1)

  • Group Key: generate_series(1, 1000)
6. 0.171 0.173 ↑ 1.0 1,000 1

ProjectSet (cost=0.00..5.02 rows=1,000 width=4) (actual time=0.009..0.173 rows=1,000 loops=1)

7. 0.002 0.002 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=1)

8. 3.000 3.000 ↑ 1.0 1 1,000

Index Scan using user1_account_id_idx on user1 (cost=0.56..8.58 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=1,000)

  • Index Cond: (account_id = (generate_series(1, 1000)))
Planning time : 0.542 ms
Execution time : 378,552.198 ms