explain.depesz.com

PostgreSQL's explain analyze made readable

Result: u7bw

Settings
# exclusive inclusive rows x rows loops node
1. 2.875 4,857.398 ↓ 0.0 0 1

Nested Loop Left Join (cost=79.37..13,166.58 rows=1 width=56) (actual time=4,857.398..4,857.398 rows=0 loops=1)

  • Join Filter: CASE WHEN (c.id = market.id) THEN (zp.market_id IS NULL) ELSE (zp.market_id = market.id) END
  • Rows Removed by Join Filter: 360
  • Filter: (zp.id IS NULL)
  • Rows Removed by Filter: 1664
2. 55.675 75.515 ↓ 15.4 1,664 1

Nested Loop (cost=79.37..1,039.79 rows=108 width=8) (actual time=0.373..75.515 rows=1,664 loops=1)

  • Join Filter: ((market.id = ANY (c.parent_ids)) OR (market.id = c.id))
  • Rows Removed by Join Filter: 262237
3. 2.392 2.392 ↑ 1.0 2,181 1

Seq Scan on customer c (cost=0.00..162.88 rows=2,276 width=27) (actual time=0.029..2.392 rows=2,181 loops=1)

  • Filter: (active = 1)
  • Rows Removed by Filter: 32
4. 15.740 17.448 ↓ 12.1 121 2,181

Materialize (cost=79.37..251.04 rows=10 width=4) (actual time=0.000..0.008 rows=121 loops=2,181)

5. 0.080 1.708 ↓ 12.1 121 1

Hash Join (cost=79.37..250.99 rows=10 width=4) (actual time=0.337..1.708 rows=121 loops=1)

  • Hash Cond: (market.id = nnsc.customer_id)
6. 1.306 1.306 ↑ 1.0 230 1

Seq Scan on customer market (cost=0.00..168.65 rows=235 width=4) (actual time=0.003..1.306 rows=230 loops=1)

  • Filter: ((level = 1) AND (active = 1))
  • Rows Removed by Filter: 1983
7. 0.030 0.322 ↓ 1.3 121 1

Hash (cost=78.19..78.19 rows=94 width=4) (actual time=0.322..0.322 rows=121 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 13kB
8. 0.250 0.292 ↓ 1.3 121 1

Bitmap Heap Scan on ninushi_customer nnsc (cost=5.25..78.19 rows=94 width=4) (actual time=0.074..0.292 rows=121 loops=1)

  • Recheck Cond: (ninushi_id = 1)
  • Filter: ((type = 1) AND (customer_id = ANY ('{1,5,6,7,8,9,12,13,14,18,19,30,31,32,33,34,35,36,37,38,39,50,51,301,308,309,310,311,314,315,316,317,318,319,320,324,325,327,332,333,337,339,360,362,363,367,372,373,374,379,384,385,392,430,451,463,475,477,481,483,484,488,489,490,491,525,528,540,561,563,564,571,572,573,574,577,580,582,608,610,636,642,651,705,730,731,732,740,741,747,755,805,842,869,895,902,1041,1075,1164,1169,1174,1204,1238,1242,1257,1268,1343,1363,1481,1489,1534,1619,1620,1746,1918,2034,2055,2175,2296,2297,2372}'::integer[])))
  • Rows Removed by Filter: 3
  • Heap Blocks: exact=16
9. 0.042 0.042 ↑ 1.0 124 1

Bitmap Index Scan on ninushi_customer_ninushi_id_customer_id_idx (cost=0.00..5.22 rows=126 width=0) (actual time=0.042..0.042 rows=124 loops=1)

  • Index Cond: (ninushi_id = 1)
10. 4.992 4,779.008 ↑ 2.0 1 1,664

Append (cost=0.00..112.26 rows=2 width=12) (actual time=0.020..2.872 rows=1 loops=1,664)

11. 3.328 3.328 ↓ 0.0 0 1,664

Seq Scan on zaiko_publish zp (cost=0.00..1.00 rows=1 width=12) (actual time=0.002..0.002 rows=0 loops=1,664)

  • Filter: ((ninushi_id = 1) AND (zaiko_group_id = 7879) AND (customer_id = c.id))
12. 4,770.688 4,770.688 ↑ 1.0 1 1,664

Index Scan using zaiko_publish_customer_id_idx on zaiko_publish zp_1 (cost=0.43..111.26 rows=1 width=12) (actual time=0.016..2.867 rows=1 loops=1,664)

  • Index Cond: (customer_id = c.id)
  • Filter: ((ninushi_id = 1) AND (zaiko_group_id = 7879))
  • Rows Removed by Filter: 2521
Planning time : 1.577 ms
Execution time : 4,857.548 ms