explain.depesz.com

PostgreSQL's explain analyze made readable

Result: EJrK

Settings
# exclusive inclusive rows x rows loops node
1. 109.372 56,264.818 ↓ 566,319.0 566,319 1

Unique (cost=16,390.91..16,390.92 rows=1 width=8) (actual time=56,018.621..56,264.818 rows=566,319 loops=1)

2. 652.831 56,155.446 ↓ 1,489,741.0 1,489,741 1

Sort (cost=16,390.91..16,390.92 rows=1 width=8) (actual time=56,018.620..56,155.446 rows=1,489,741 loops=1)

  • Sort Key: ml1.id, ml2.id
  • Sort Method: quicksort Memory: 118984kB
3. 22,454.888 55,502.615 ↓ 1,489,741.0 1,489,741 1

Nested Loop (cost=7,713.09..16,390.90 rows=1 width=8) (actual time=35.353..55,502.615 rows=1,489,741 loops=1)

  • Join Filter: ((ml2.lot_id IS NULL) OR (ml2.lot_id = q2.lot_id))
  • Rows Removed by Join Filter: 216413876
4. 857.795 1,763.166 ↓ 1,489,741.0 1,489,741 1

Gather (cost=7,712.66..16,317.31 rows=1 width=16) (actual time=35.349..1,763.166 rows=1,489,741 loops=1)

  • Workers Planned: 1
  • Workers Launched: 1
5. 296.975 905.371 ↓ 744,870.0 744,870 2 / 2

Nested Loop (cost=6,712.66..15,317.21 rows=1 width=16) (actual time=28.757..905.371 rows=744,870 loops=2)

  • Join Filter: ((ml1.lot_id IS NULL) OR (ml1.lot_id = q1.lot_id))
  • Rows Removed by Join Filter: 628598
6. 0.000 207.161 ↓ 495.3 13,374 2 / 2

Nested Loop (cost=6,712.24..13,330.30 rows=27 width=24) (actual time=28.725..207.161 rows=13,374 loops=2)

  • Join Filter: (((m1.raw_material_production_id IS NOT NULL) AND (m2.production_id IS NOT NULL)) OR ((m1.consume_unbuild_id IS NOT NULL) AND (m2.unbuild_id IS NOT NULL)))
7. 13.564 155.619 ↓ 27.2 26,780 2 / 2

Nested Loop (cost=6,711.95..13,002.98 rows=985 width=28) (actual time=28.708..155.619 rows=26,780 loops=2)

  • Join Filter: (sqcr.produce_quant_id = sqmr2.quant_id)
8. 0.121 115.306 ↓ 11.3 13,374 2 / 2

Nested Loop (cost=6,711.53..12,387.38 rows=1,186 width=32) (actual time=28.694..115.306 rows=13,374 loops=2)

9. 1.992 88.436 ↓ 11.3 13,374 2 / 2

Nested Loop (cost=6,711.10..11,760.08 rows=1,186 width=24) (actual time=28.689..88.436 rows=13,374 loops=2)

  • Join Filter: (sqcr.consume_quant_id = q1.id)
10. 5.160 59.695 ↓ 2.7 13,374 2 / 2

Merge Join (cost=6,710.68..9,437.68 rows=4,888 width=28) (actual time=28.658..59.695 rows=13,374 loops=2)

  • Merge Cond: (sqmr1.quant_id = sqcr.consume_quant_id)
11. 6.933 29.028 ↑ 1.7 3,374 2 / 2

Sort (cost=6,705.19..6,719.23 rows=5,617 width=20) (actual time=28.627..29.028 rows=3,374 loops=2)

  • Sort Key: sqmr1.quant_id
  • Sort Method: quicksort Memory: 1937kB
12. 3.380 22.095 ↓ 4.9 27,310 2 / 2

Nested Loop (cost=39.39..6,355.37 rows=5,617 width=20) (actual time=4.954..22.095 rows=27,310 loops=2)

13. 5.498 5.807 ↑ 2.1 922 2 / 2

Parallel Bitmap Heap Scan on stock_move m1 (cost=38.97..2,378.79 rows=1,923 width=12) (actual time=4.884..5.807 rows=922 loops=2)

  • Recheck Cond: ((raw_material_production_id IS NOT NULL) OR (consume_unbuild_id IS NOT NULL))
  • Heap Blocks: exact=893
14. 0.001 0.309 ↓ 0.0 0 1 / 2

BitmapOr (cost=38.97..38.97 rows=3,269 width=0) (actual time=0.619..0.619 rows=0 loops=1)

15. 0.294 0.294 ↓ 1.1 3,688 1 / 2

Bitmap Index Scan on sm_raw_material_production_id_idx (cost=0.00..35.93 rows=3,269 width=0) (actual time=0.589..0.589 rows=3,688 loops=1)

  • Index Cond: (raw_material_production_id IS NOT NULL)
16. 0.015 0.015 ↓ 0.0 0 1 / 2

Bitmap Index Scan on stock_move_consume_unbuild_id_fkey_mig_10_0_idx (cost=0.00..1.40 rows=1 width=0) (actual time=0.029..0.029 rows=0 loops=1)

  • Index Cond: (consume_unbuild_id IS NOT NULL)
17. 12.908 12.908 ↓ 1.2 30 1,844 / 2

Index Scan using stock_quant_move_rel_move_id_idx on stock_quant_move_rel sqmr1 (cost=0.42..1.81 rows=26 width=8) (actual time=0.007..0.014 rows=30 loops=1,844)

  • Index Cond: (move_id = m1.id)
18. 25.507 25.507 ↑ 3.5 26,903 2 / 2

Index Scan using sqcr_consume_quant_id_idx on stock_quant_consume_rel sqcr (cost=0.43..2,421.36 rows=93,681 width=8) (actual time=0.023..25.507 rows=26,903 loops=2)

  • Index Cond: (consume_quant_id < 37000)
19. 26.749 26.749 ↑ 1.0 1 26,749 / 2

Index Scan using stock_quant_pkey on stock_quant q1 (cost=0.42..0.46 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=26,749)

  • Index Cond: (id = sqmr1.quant_id)
20. 26.749 26.749 ↑ 1.0 1 26,749 / 2

Index Scan using stock_quant_pkey on stock_quant q2 (cost=0.42..0.53 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=26,749)

  • Index Cond: (id = sqcr.produce_quant_id)
21. 26.749 26.749 ↑ 1.5 2 26,749 / 2

Index Scan using sqmr_quant_id_idx on stock_quant_move_rel sqmr2 (cost=0.42..0.48 rows=3 width=8) (actual time=0.002..0.002 rows=2 loops=26,749)

  • Index Cond: (quant_id = q2.id)
22. 53.559 53.559 ↓ 0.0 0 53,559 / 2

Index Scan using stock_move_pkey on stock_move m2 (cost=0.29..0.32 rows=1 width=12) (actual time=0.002..0.002 rows=0 loops=53,559)

  • Index Cond: (id = sqmr2.move_id)
  • Filter: ((production_id IS NOT NULL) OR (unbuild_id IS NOT NULL))
  • Rows Removed by Filter: 1
23. 401.235 401.235 ↑ 23.7 103 26,749 / 2

Index Scan using stock_move_line_move_id_index on stock_move_line ml1 (cost=0.42..43.11 rows=2,438 width=12) (actual time=0.003..0.030 rows=103 loops=26,749)

  • Index Cond: (move_id = sqmr1.move_id)
24. 31,284.561 31,284.561 ↑ 16.7 146 1,489,741

Index Scan using stock_move_line_move_id_index on stock_move_line ml2 (cost=0.42..43.11 rows=2,438 width=12) (actual time=0.002..0.021 rows=146 loops=1,489,741)

  • Index Cond: (move_id = sqmr2.move_id)
Planning time : 18.783 ms
Execution time : 56,277.116 ms