explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CCIz

Settings
# exclusive inclusive rows x rows loops node
1. 0.003 56,408.867 ↑ 1.0 10 1

Limit (cost=16,196,784.42..16,196,786.17 rows=10 width=2,536) (actual time=56,408.852..56,408.867 rows=10 loops=1)

2. 0.013 56,408.864 ↑ 235,859.8 10 1

Unique (cost=16,196,784.42..16,609,539.07 rows=2,358,598 width=2,536) (actual time=56,408.851..56,408.864 rows=10 loops=1)

3. 134.936 56,408.851 ↑ 235,859.8 10 1

Sort (cost=16,196,784.42..16,202,680.91 rows=2,358,598 width=2,536) (actual time=56,408.850..56,408.851 rows=10 loops=1)

  • Sort Key: inspections_booking.last_updated_time DESC, inspections_booking.id, inspections_booking.uuid, inspections_booking.assignment_uuid, inspections_booking.inspection_uuid, inspections_booking.pi_number, inspections_booking.country_of_shipment, inspections_booking.inspection_type_id, inspections_booking.shipment_date, inspections_booking.expected_inspection_date, inspections_booking.actual_inspection_date, inspections_booking.status, inspections_booking.case_number, inspections_booking.current_number, inspections_booking.executor_id, inspections_booking.book_from_org_id, inspections_booking.inspection_location_information_id, inspections_booking.supplier_information_id, inspections_booking.factory_information_id, inspections_booking.retailer_information_id, inspections_booking.inspector_id, inspections_booking.tentative_workflow, inspections_booking.workflow_id, inspections_booking.saved_workflow_id, inspections_booking.creator_id, inspections_booking.released_by_user_id, inspections_booking.approved_by_user_id, inspections_booking.confirmed_by_id, inspections_booking.approved_date, inspections_booking.utc_offset, inspections_booking.capa, inspections_booking.created_time, inspections_booking.last_updated_by_id, inspections_booking.remark, inspections_booking.split_from_id, inspections_booking.clone_from_id, inspections_booking.split_allowed, inspections_booking.shared_to_stakeholders, inspections_booking.booking_ids, ((inspections_booking.inspection_location)::bytea), inspections_booking.inspection_location_country, inspections_booking.inspection_location_city, inspections_booking.inspection_location_district, inspections_booking.inspection_start_time, inspections_booking.inspection_end_time, inspections_booking.inspection_total_time, inspections_booking.inspection_result, inspections_booking.inspection_total_quantity, inspections_booking.report_pdf, inspections_booking.description, inspections_booking.tech_pack, inspections_booking.purchase_order, inspections_booking.order_quantity, inspections_booking.available_quantity, inspections_booking.previous_inspection_id, inspections_booking.previous_assignment_id, inspections_booking.previous_booking_id, inspections_booking.only_fail_ppm_question, inspections_booking.booking_template_history_id, inspections_booking.fe_draft_id, inspections_booking.assignment_status, inspections_booking.assignment_executor_id, inspections_booking.auto_assign, inspections_booking.case_id, inspections_booking.inactive_time, (string_agg(DISTINCT (inspections_purchaseorder.po_number)::text, ','::text)), (string_agg(DISTINCT (inspections_purchaseorder.opo_number)::text, ','::text)), (count(inspections_bookingitem.id)), (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
  • Sort Method: external merge Disk: 29248kB
4. 4,443.265 56,273.915 ↑ 36.3 64,974 1

GroupAggregate (cost=8,066,465.86..8,207,981.74 rows=2,358,598 width=2,536) (actual time=50,223.933..56,273.915 rows=64,974 loops=1)

  • Group Key: inspections_booking.id, (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
5. 44,799.800 51,830.650 ↓ 1.6 3,871,887 1

Sort (cost=8,066,465.86..8,072,362.35 rows=2,358,598 width=2,479) (actual time=50,223.876..51,830.650 rows=3,871,887 loops=1)

  • Sort Key: inspections_booking.id, (concat(accounts_user.first_name, concat(' ', accounts_user.last_name)))
  • Sort Method: external merge Disk: 1787232kB
6. 5,858.359 7,030.850 ↓ 1.6 3,871,887 1

Hash Join (cost=99,760.14..246,954.68 rows=2,358,598 width=2,479) (actual time=652.360..7,030.850 rows=3,871,887 loops=1)

  • Hash Cond: (inspections_bookingitem.booking_id = inspections_booking.id)
7. 276.478 534.530 ↑ 1.0 1,486,745 1

Hash Join (cost=1,322.37..55,009.35 rows=1,516,336 width=8) (actual time=12.104..534.530 rows=1,486,745 loops=1)

  • Hash Cond: (inspections_bookingitem.product_category_id = datasource_productcategory.id)
8. 246.174 246.174 ↑ 1.0 1,486,745 1

Seq Scan on inspections_bookingitem (cost=0.00..32,837.36 rows=1,516,336 width=12) (actual time=0.091..246.174 rows=1,486,745 loops=1)

9. 3.543 11.878 ↑ 1.0 25,235 1

Hash (cost=1,006.93..1,006.93 rows=25,235 width=4) (actual time=11.878..11.878 rows=25,235 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1144kB
10. 6.199 8.335 ↑ 1.0 25,235 1

Hash Join (cost=37.60..1,006.93 rows=25,235 width=4) (actual time=0.345..8.335 rows=25,235 loops=1)

  • Hash Cond: (datasource_productcategory.product_line_id = datasource_productline.id)
11. 1.889 1.889 ↑ 1.0 25,235 1

Seq Scan on datasource_productcategory (cost=0.00..622.35 rows=25,235 width=8) (actual time=0.089..1.889 rows=25,235 loops=1)

12. 0.123 0.247 ↑ 1.0 871 1

Hash (cost=26.71..26.71 rows=871 width=4) (actual time=0.247..0.247 rows=871 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 39kB
13. 0.124 0.124 ↑ 1.0 871 1

Seq Scan on datasource_productline (cost=0.00..26.71 rows=871 width=4) (actual time=0.004..0.124 rows=871 loops=1)

14. 159.310 637.961 ↓ 1.1 137,166 1

Hash (cost=58,146.05..58,146.05 rows=127,418 width=2,458) (actual time=637.961..637.961 rows=137,166 loops=1)

  • Buckets: 2048 Batches: 128 Memory Usage: 629kB
15. 52.094 478.651 ↓ 1.1 137,166 1

Hash Join (cost=34,324.73..58,146.05 rows=127,418 width=2,458) (actual time=240.039..478.651 rows=137,166 loops=1)

  • Hash Cond: (inspections_booking.creator_id = accounts_user.id)
16. 57.340 425.033 ↓ 1.1 137,166 1

Merge Join (cost=34,148.99..56,218.31 rows=127,418 width=2,447) (actual time=238.469..425.033 rows=137,166 loops=1)

  • Merge Cond: (inspections_booking.id = inspections_booking_purchase_orders.booking_id)
17. 85.999 85.999 ↑ 1.0 65,710 1

Index Scan using inspections_booking_pkey on inspections_booking (cost=0.29..20,069.67 rows=66,189 width=2,432) (actual time=0.009..85.999 rows=65,710 loops=1)

  • Filter: (book_to_org_id = 252437)
  • Rows Removed by Filter: 15809
18. 16.269 281.694 ↑ 1.0 157,696 1

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

19. 99.556 265.425 ↑ 1.0 157,696 1

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

  • Sort Key: inspections_booking_purchase_orders.booking_id
  • Sort Method: external merge Disk: 3560kB
20. 76.658 165.869 ↑ 1.0 157,696 1

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

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

22. 38.121 69.774 ↓ 1.0 199,695 1

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

  • Buckets: 131072 Batches: 4 Memory Usage: 3327kB
23. 31.653 31.653 ↓ 1.0 199,695 1

Seq Scan on inspections_purchaseorder (cost=0.00..6,130.71 rows=199,671 width=15) (actual time=0.083..31.653 rows=199,695 loops=1)

24. 0.784 1.524 ↑ 1.0 4,305 1

Hash (cost=121.44..121.44 rows=4,344 width=15) (actual time=1.524..1.524 rows=4,305 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 274kB
25. 0.740 0.740 ↑ 1.0 4,305 1

Seq Scan on accounts_user (cost=0.00..121.44 rows=4,344 width=15) (actual time=0.005..0.740 rows=4,305 loops=1)

Planning time : 4.482 ms
Execution time : 56,683.206 ms