explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CTaA

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 18,897.815 ↑ 1.0 10 1

Limit (cost=8,234,188.24..8,234,188.27 rows=10 width=2,536) (actual time=18,897.812..18,897.815 rows=10 loops=1)

2. 63.980 18,897.813 ↑ 235,931.0 10 1

Sort (cost=8,234,188.24..8,240,086.52 rows=2,359,310 width=2,536) (actual time=18,897.811..18,897.813 rows=10 loops=1)

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

GroupAggregate (cost=8,041,645.80..8,183,204.40 rows=2,359,310 width=2,536) (actual time=13,322.128..18,833.833 rows=65,710 loops=1)

  • Group Key: inspections_booking.id, (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
4. 8,312.320 14,377.837 ↓ 1.6 3,884,523 1

Sort (cost=8,041,645.80..8,047,544.08 rows=2,359,310 width=2,479) (actual time=13,313.981..14,377.837 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,473.238 6,065.517 ↓ 1.6 3,884,523 1

Merge Left Join (cost=34,149.40..219,765.12 rows=2,359,310 width=2,479) (actual time=250.821..6,065.517 rows=3,884,523 loops=1)

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

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

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

Nested Loop (cost=0.57..41,175.25 rows=66,209 width=2,443) (actual time=0.015..327.052 rows=65,710 loops=1)

8. 135.880 135.880 ↑ 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.011..135.880 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. 22.254 313.766 ↑ 1.0 157,696 1

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

11. 116.535 291.512 ↑ 1.0 157,696 1

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

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

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

  • Hash Cond: (inspections_booking_purchase_orders.purchaseorder_id = inspections_purchaseorder.id)
13. 22.356 22.356 ↑ 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.092..22.356 rows=157,696 loops=1)

14. 39.357 72.341 ↓ 1.0 199,682 1

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

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

Seq Scan on inspections_purchaseorder (cost=0.00..6,130.71 rows=199,671 width=15) (actual time=0.084..32.984 rows=199,682 loops=1)

16. 392.060 861.757 ↓ 2.6 4,003,376 1

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

17. 469.697 469.697 ↑ 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.013..469.697 rows=1,486,711 loops=1)

Planning time : 2.902 ms
Execution time : 19,166.641 ms