explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 9vdm

Settings
# exclusive inclusive rows x rows loops node
1. 0.002 2,171.038 ↑ 1.0 10 1

Limit (cost=9,441,432.51..9,441,432.53 rows=10 width=2,504) (actual time=2,171.031..2,171.038 rows=10 loops=1)

2. 54.759 2,171.036 ↑ 6,620.9 10 1

Sort (cost=9,441,432.51..9,441,598.03 rows=66,209 width=2,504) (actual time=2,171.030..2,171.036 rows=10 loops=1)

  • Sort Key: inspections_booking.last_updated_time DESC
  • Sort Method: top-N heapsort Memory: 33kB
3. 342.839 2,116.277 ↑ 1.0 65,710 1

GroupAggregate (cost=6,325,474.79..9,440,001.76 rows=66,209 width=2,504) (actual time=1,728.066..2,116.277 rows=65,710 loops=1)

  • Group Key: inspections_booking.id, ((SubPlan 1))
4. 289.860 1,773.438 ↓ 1.1 137,902 1

Sort (cost=6,325,474.79..6,325,793.44 rows=127,457 width=2,451) (actual time=1,728.000..1,773.438 rows=137,902 loops=1)

  • Sort Key: inspections_booking.id, ((SubPlan 1))
  • Sort Method: external sort Disk: 62208kB
5. 132.048 1,483.578 ↓ 1.1 137,902 1

Merge Left Join (cost=34,148.69..6,044,564.66 rows=127,457 width=2,451) (actual time=243.278..1,483.578 rows=137,902 loops=1)

  • Merge Cond: (inspections_booking.id = inspections_booking_purchase_orders.booking_id)
6. 95.850 95.850 ↑ 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.013..95.850 rows=65,710 loops=1)

  • Filter: ((book_to_org_id = 252437) OR (executor_id = 252437))
  • Rows Removed by Filter: 15809
7. 18.482 290.366 ↑ 1.0 157,696 1

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

8. 101.818 271.884 ↑ 1.0 157,696 1

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

  • Sort Key: inspections_booking_purchase_orders.booking_id
  • Sort Method: external merge Disk: 3560kB
9. 78.997 170.066 ↑ 1.0 157,696 1

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

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

11. 38.846 71.386 ↓ 1.0 199,694 1

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

  • Buckets: 131072 Batches: 4 Memory Usage: 3327kB
12. 32.540 32.540 ↓ 1.0 199,694 1

Seq Scan on inspections_purchaseorder (cost=0.00..6,130.71 rows=199,671 width=15) (actual time=0.087..32.540 rows=199,694 loops=1)

13.          

SubPlan (forMerge Left Join)

14. 275.804 965.314 ↑ 1.0 1 137,902

Aggregate (cost=46.97..46.98 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=137,902)

15. 689.510 689.510 ↑ 1.3 28 137,902

Index Only Scan using inspections_bookingitem_booking_id_581db468 on inspections_bookingitem u0 (cost=0.43..46.88 rows=36 width=0) (actual time=0.002..0.005 rows=28 loops=137,902)

  • Index Cond: (booking_id = inspections_booking.id)
  • Heap Fetches: 1458376
Planning time : 0.717 ms
Execution time : 2,184.629 ms