explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mwvQ : Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: Optimization for: plan #PTt4; plan #1SCb; plan #3jBG; plan #eE6h; plan #i2qD; plan #tQzX; plan #Mys4; plan #cJmw; plan #SAeq; plan #uq9X; plan #V9og; plan #QmWj4; plan #GiTt; plan #SiSO; plan #f6PS; plan #X2Md

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.069 2.975 ↓ 10.0 10 1

Insert on transfer_reagents (cost=343,134.35..343,144.22 rows=1 width=1,104) (actual time=2.798..2.975 rows=10 loops=1)

2.          

CTE to_upsert

3. 0.138 0.138 ↑ 10.0 10 1

Function Scan on json_to_recordset to_upsert (cost=0.00..1.00 rows=100 width=353) (actual time=0.137..0.138 rows=10 loops=1)

4.          

CTE plates

5. 0.006 0.116 ↑ 100.0 2 1

Unique (cost=1,684.17..1,686.67 rows=200 width=38) (actual time=0.109..0.116 rows=2 loops=1)

6. 0.012 0.110 ↑ 20.0 10 1

Sort (cost=1,684.17..1,684.67 rows=200 width=38) (actual time=0.109..0.110 rows=10 loops=1)

  • Sort Key: pl.id, pl.barcode, pl.experiment_plate_number, e.label
  • Sort Method: quicksort Memory: 25kB
7. 0.012 0.098 ↑ 20.0 10 1

Nested Loop (cost=8.54..1,676.52 rows=200 width=38) (actual time=0.020..0.098 rows=10 loops=1)

8. 0.018 0.066 ↑ 20.0 10 1

Nested Loop (cost=8.25..1,605.17 rows=200 width=19) (actual time=0.014..0.066 rows=10 loops=1)

9. 0.008 0.008 ↑ 10.0 10 1

CTE Scan on to_upsert tu_1 (cost=0.00..2.00 rows=100 width=36) (actual time=0.000..0.008 rows=10 loops=1)

10. 0.010 0.040 ↑ 2.0 1 10

Bitmap Heap Scan on plates pl (cost=8.25..16.01 rows=2 width=19) (actual time=0.004..0.004 rows=1 loops=10)

  • Recheck Cond: ((tu_1.plate_id = id) OR ((tu_1.plate_barcode)::text = (barcode)::text))
  • Heap Blocks: exact=10
11. 0.010 0.030 ↓ 0.0 0 10

BitmapOr (cost=8.25..8.25 rows=2 width=0) (actual time=0.003..0.003 rows=0 loops=10)

12. 0.020 0.020 ↑ 1.0 1 10

Bitmap Index Scan on plates_pkey (cost=0.00..4.11 rows=1 width=0) (actual time=0.002..0.002 rows=1 loops=10)

  • Index Cond: (tu_1.plate_id = id)
13. 0.000 0.000 ↓ 0.0 0 10

Bitmap Index Scan on idx_plates_barcode (cost=0.00..4.14 rows=1 width=0) (actual time=0.000..0.000 rows=0 loops=10)

  • Index Cond: ((tu_1.plate_barcode)::text = (barcode)::text)
14. 0.020 0.020 ↑ 1.0 1 10

Index Scan using experiments_pkey on experiments e (cost=0.29..0.35 rows=1 width=27) (actual time=0.002..0.002 rows=1 loops=10)

  • Index Cond: (id = pl.experiment_id)
15.          

CTE printings

16. 0.010 0.236 ↓ 3.0 6 1

Unique (cost=340,831.57..340,831.60 rows=2 width=20) (actual time=0.223..0.236 rows=6 loops=1)

17. 0.017 0.226 ↓ 10.0 20 1

Sort (cost=340,831.57..340,831.58 rows=2 width=20) (actual time=0.222..0.226 rows=20 loops=1)

  • Sort Key: p.id, p.plate_id, p.layer, p.printed_at
  • Sort Method: quicksort Memory: 25kB
18. 0.045 0.209 ↓ 10.0 20 1

Nested Loop (cost=0.56..340,831.56 rows=2 width=20) (actual time=0.132..0.209 rows=20 loops=1)

  • Join Filter: ((tu_2.printing_id = p.id) OR (((tu_2.layer)::text = ((p.layer)::character varying)::text) AND (plates_1.id = p.plate_id) AND CASE WHEN (tu_2.printed_at IS NULL) THEN (p.printed_at IS NULL) ELSE (p.printed_at IS NOT NULL) END))
  • Rows Removed by Join Filter: 40
19. 0.004 0.004 ↑ 10.0 10 1

CTE Scan on to_upsert tu_2 (cost=0.00..2.00 rows=100 width=44) (actual time=0.001..0.004 rows=10 loops=1)

20. 0.018 0.160 ↑ 8,554.7 6 10

Materialize (cost=0.56..212,637.88 rows=51,328 width=24) (actual time=0.012..0.016 rows=6 loops=10)

21. 0.005 0.142 ↑ 8,554.7 6 1

Nested Loop (cost=0.56..212,381.24 rows=51,328 width=24) (actual time=0.119..0.142 rows=6 loops=1)

22. 0.119 0.119 ↑ 100.0 2 1

CTE Scan on plates plates_1 (cost=0.00..4.00 rows=200 width=4) (actual time=0.110..0.119 rows=2 loops=1)

23. 0.018 0.018 ↑ 85.7 3 2

Index Scan using printings_plate_id_idx on printings p (cost=0.56..1,059.32 rows=257 width=20) (actual time=0.005..0.009 rows=3 loops=2)

  • Index Cond: (plate_id = plates_1.id)
24.          

CTE new_transfer_perturbations

25. 2.125 2.565 ↓ 2.5 10 1

Insert on transfer_perturbations (cost=614.58..614.94 rows=4 width=1,435) (actual time=0.903..2.565 rows=10 loops=1)

26. 0.050 0.440 ↓ 2.5 10 1

Subquery Scan on *SELECT* (cost=614.58..614.94 rows=4 width=1,435) (actual time=0.371..0.440 rows=10 loops=1)

27. 0.035 0.390 ↓ 2.5 10 1

GroupAggregate (cost=614.58..614.74 rows=4 width=269) (actual time=0.357..0.390 rows=10 loops=1)

  • Group Key: tu_3.well_address, tu_3.src_barcode, tu_3.src_address, tu_3.transfer_volume, printings_1.id, tu_3.condition_id, tu_3.well_type_id, tu_3.control
28. 0.027 0.355 ↓ 2.5 10 1

Sort (cost=614.58..614.59 rows=4 width=237) (actual time=0.352..0.355 rows=10 loops=1)

  • Sort Key: tu_3.well_address, tu_3.src_barcode, tu_3.src_address, tu_3.transfer_volume, printings_1.id, tu_3.condition_id, tu_3.well_type_id, tu_3.control
  • Sort Method: quicksort Memory: 26kB
29. 0.040 0.328 ↓ 2.5 10 1

Nested Loop (cost=0.00..614.54 rows=4 width=237) (actual time=0.256..0.328 rows=10 loops=1)

  • Join Filter: ((printings_1.id = tu_3.printing_id) OR ((((printings_1.layer)::character varying)::text = (tu_3.layer)::text) AND (plates_2.id = printings_1.plate_id)))
  • Rows Removed by Join Filter: 50
30. 0.240 0.240 ↓ 3.0 6 1

CTE Scan on printings printings_1 (cost=0.00..0.04 rows=2 width=12) (actual time=0.224..0.240 rows=6 loops=1)

31. 0.020 0.048 ↑ 20.0 10 6

Materialize (cost=0.00..605.00 rows=200 width=273) (actual time=0.001..0.008 rows=10 loops=6)

32. 0.013 0.028 ↑ 20.0 10 1

Nested Loop (cost=0.00..604.00 rows=200 width=273) (actual time=0.003..0.028 rows=10 loops=1)

  • Join Filter: ((tu_3.plate_id = plates_2.id) OR ((tu_3.plate_barcode)::text = (plates_2.barcode)::text) OR (((tu_3.experiment_label)::text = (plates_2.experiment_label)::text) AND (tu_3.plate_number = plates_2.experiment_plate_number)))
  • Rows Removed by Join Filter: 10
33. 0.005 0.005 ↑ 10.0 10 1

CTE Scan on to_upsert tu_3 (cost=0.00..2.00 rows=100 width=341) (actual time=0.001..0.005 rows=10 loops=1)

34. 0.010 0.010 ↑ 100.0 2 10

CTE Scan on plates plates_2 (cost=0.00..4.00 rows=200 width=742) (actual time=0.000..0.001 rows=2 loops=10)

35. 0.060 2.906 ↓ 10.0 10 1

Nested Loop (cost=0.14..10.01 rows=1 width=1,104) (actual time=2.766..2.906 rows=10 loops=1)

  • Join Filter: ((ntp.printing_id = printings.id) AND ((printings.id = tu.printing_id) OR ((((printings.layer)::character varying)::text = (tu.layer)::text) AND (plates.id = printings.plate_id))))
  • Rows Removed by Join Filter: 98
36. 0.022 2.810 ↓ 18.0 18 1

Nested Loop (cost=0.14..9.91 rows=1 width=144) (actual time=2.745..2.810 rows=18 loops=1)

  • Join Filter: ((plates.id = tu.plate_id) OR ((plates.barcode)::text = (tu.plate_barcode)::text))
  • Rows Removed by Join Filter: 18
37. 0.034 2.770 ↓ 18.0 18 1

Hash Join (cost=0.14..2.91 rows=1 width=176) (actual time=2.743..2.770 rows=18 loops=1)

  • Hash Cond: (((tu.src_barcode)::text = (ntp.src_plate_barcode)::text) AND ((tu.src_address)::text = (ntp.src_well_address)::text))
  • Join Filter: ((tu.well_address)::text = ANY ((ntp.addresses)::text[]))
  • Rows Removed by Join Filter: 34
38. 0.144 0.144 ↑ 10.0 10 1

CTE Scan on to_upsert tu (cost=0.00..2.00 rows=100 width=264) (actual time=0.139..0.144 rows=10 loops=1)

39. 0.011 2.592 ↓ 2.5 10 1

Hash (cost=0.08..0.08 rows=4 width=282) (actual time=2.592..2.592 rows=10 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
40. 2.581 2.581 ↓ 2.5 10 1

CTE Scan on new_transfer_perturbations ntp (cost=0.00..0.08 rows=4 width=282) (actual time=0.905..2.581 rows=10 loops=1)

41. 0.018 0.018 ↑ 100.0 2 18

CTE Scan on plates (cost=0.00..4.00 rows=200 width=222) (actual time=0.000..0.001 rows=2 loops=18)

42. 0.036 0.036 ↓ 3.0 6 18

CTE Scan on printings (cost=0.00..0.04 rows=2 width=12) (actual time=0.000..0.002 rows=6 loops=18)

Planning time : 1.264 ms
Trigger times:
Trigger Name:Total time:Calls:Average time:
for constraint transfer_reagents_transfer_perturbation_id_fkey on transfer_reagents 0.095 ms 10 0.009 ms
for constraint printing_prescription_conditions_id_fkey on transfer_perturbations 0.172 ms 10 0.017 ms
for constraint printing_reagents_well_type_id_fkey on transfer_perturbations 0.117 ms 10 0.012 ms
for constraint printing_reagents_printing_id_fkey on transfer_perturbations 0.413 ms 10 0.041 ms
platelet_printings_reagents_updated_at on transfer_perturbations 1.522 ms 10 0.152 ms