explain.depesz.com

PostgreSQL's explain analyze made readable

Result: pNv3

Settings
# exclusive inclusive rows x rows loops node
1. 0.001 18,159.110 ↑ 1.0 10 1

Limit (cost=8,234,192.24..8,234,192.27 rows=10 width=2,536) (actual time=18,159.101..18,159.110 rows=10 loops=1)

2. 62.808 18,159.109 ↑ 235,931.0 10 1

Sort (cost=8,234,192.24..8,240,090.52 rows=2,359,310 width=2,536) (actual time=18,159.101..18,159.109 rows=10 loops=1)

  • Sort Key: inspections_booking.last_updated_time DESC
  • Sort Method: top-N heapsort Memory: 33kB
3. 4,382.322 18,096.301 ↑ 35.9 65,710 1

GroupAggregate (cost=8,041,649.80..8,183,208.40 rows=2,359,310 width=2,536) (actual time=12,671.317..18,096.301 rows=65,710 loops=1)

  • Group Key: inspections_booking.id, (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
4. 7,873.849 13,713.979 ↓ 1.6 3,884,523 1

Sort (cost=8,041,649.80..8,047,548.08 rows=2,359,310 width=2,479) (actual time=12,671.253..13,713.979 rows=3,884,523 loops=1)

  • Sort Key: inspections_booking.id, (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
  • Sort Method: external sort Disk: 1792144kB
5. 4,350.919 5,840.130 ↓ 1.6 3,884,523 1

Merge Left Join (cost=34,149.40..219,769.12 rows=2,359,310 width=2,479) (actual time=236.326..5,840.130 rows=3,884,523 loops=1)

  • Merge Cond: (inspections_booking.id = inspections_bookingitem.booking_id)
6. 82.875 683.583 ↓ 1.1 137,902 1

Merge Left Join (cost=34,148.97..77,950.46 rows=127,457 width=2,454) (actual time=236.293..683.583 rows=137,902 loops=1)

  • Merge Cond: (inspections_booking.id = inspections_booking_purchase_orders.booking_id)
7. 45.589 305.989 ↑ 1.0 65,710 1

Nested Loop (cost=0.57..41,179.25 rows=66,209 width=2,443) (actual time=0.017..305.989 rows=65,710 loops=1)

8. 128.980 128.980 ↑ 1.0 65,710 1

Index Scan using inspections_booking_pkey on inspections_booking (cost=0.29..20,274.46 rows=66,209 width=2,432) (actual time=0.012..128.980 rows=65,710 loops=1)

  • Filter: ((book_to_org_id = 252437) OR (executor_id = 252437))
  • Rows Removed by Filter: 15809
9. 131.420 131.420 ↑ 1.0 1 65,710

Index Scan using accounts_user_pkey on accounts_user (cost=0.28..0.31 rows=1 width=15) (actual time=0.002..0.002 rows=1 loops=65,710)

  • Index Cond: (id = inspections_booking.creator_id)
10. 21.076 294.719 ↑ 1.0 157,696 1

Materialize (cost=34,148.39..34,936.87 rows=157,696 width=15) (actual time=236.270..294.719 rows=157,696 loops=1)

11. 108.996 273.643 ↑ 1.0 157,696 1

Sort (cost=34,148.39..34,542.63 rows=157,696 width=15) (actual time=236.268..273.643 rows=157,696 loops=1)

  • Sort Key: inspections_booking_purchase_orders.booking_id
  • Sort Method: external merge Disk: 3560kB
12. 74.799 164.647 ↑ 1.0 157,696 1

Hash Left Join (cost=9,601.60..17,838.88 rows=157,696 width=15) (actual time=70.796..164.647 rows=157,696 loops=1)

  • Hash Cond: (inspections_booking_purchase_orders.purchaseorder_id = inspections_purchaseorder.id)
13. 19.751 19.751 ↑ 1.0 157,696 1

Seq Scan on inspections_booking_purchase_orders (cost=0.00..3,861.96 rows=157,696 width=8) (actual time=0.094..19.751 rows=157,696 loops=1)

14. 37.950 70.097 ↓ 1.0 199,696 1

Hash (cost=6,130.71..6,130.71 rows=199,671 width=15) (actual time=70.097..70.097 rows=199,696 loops=1)

  • Buckets: 131072 Batches: 4 Memory Usage: 3327kB
15. 32.147 32.147 ↓ 1.0 199,696 1

Seq Scan on inspections_purchaseorder (cost=0.00..6,130.71 rows=199,671 width=15) (actual time=0.086..32.147 rows=199,696 loops=1)

16. 371.324 805.628 ↓ 2.6 4,003,376 1

Materialize (cost=0.43..98,104.66 rows=1,516,336 width=8) (actual time=0.017..805.628 rows=4,003,376 loops=1)

17. 434.304 434.304 ↑ 1.0 1,486,711 1

Index Scan using inspections_bookingitem_booking_id_581db468 on inspections_bookingitem (cost=0.43..94,313.82 rows=1,516,336 width=8) (actual time=0.014..434.304 rows=1,486,711 loops=1)