explain.depesz.com

PostgreSQL's explain analyze made readable

Result: OGUN

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Limit (cost=3,310,340.99..3,310,341.04 rows=20 width=1,751) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Sort (cost=3,310,340.99..3,310,346.13 rows=2,057 width=1,751) (actual rows= loops=)

  • Sort Key: o.status_updated_at DESC, o.id
3. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,177.04..3,310,286.26 rows=2,057 width=1,751) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1,176.32..80,661.00 rows=2,057 width=1,507) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=1,176.03..79,235.69 rows=2,057 width=1,496) (actual rows= loops=)

  • Hash Cond: (da.country_id = dac.id)
6. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=589.68..78,621.05 rows=2,057 width=1,485) (actual rows= loops=)

  • Hash Cond: (pa.country_id = pac.id)
7. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=3.33..78,006.42 rows=2,057 width=1,474) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.89..60,911.05 rows=2,057 width=1,241) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.46..43,815.69 rows=2,057 width=1,008) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.02..26,720.33 rows=2,057 width=775) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.73..23,030.09 rows=2,057 width=757) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.29..5,721.58 rows=2,057 width=675) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.15..5,350.75 rows=2,057 width=675) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.58..16.63 rows=1 width=58) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Index Scan using organizations_pkey on organizations org (cost=0.29..8.31 rows=1 width=22) (actual rows= loops=)

  • Index Cond: (party_id = 58197)
16. 0.000 0.000 ↓ 0.0

Index Scan using parties_pkey on parties org_party (cost=0.29..8.31 rows=1 width=40) (actual rows= loops=)

  • Index Cond: (id = 58197)
17. 0.000 0.000 ↓ 0.0

Index Scan using orders_party_id_idx on orders o (cost=0.56..5,313.55 rows=2,057 width=617) (actual rows= loops=)

  • Index Cond: (party_id = 58197)
  • Filter: (status = ANY ('{for_pickup,picked_up,failed_pickup,failed_delivery,in_transit,claimed,delivered,return_in_transit,returned,failed_return,out_fo
18. 0.000 0.000 ↓ 0.0

Index Scan using currencies_pkey on currencies c (cost=0.14..0.17 rows=1 width=8) (actual rows= loops=)

  • Index Cond: (id = o.currency_id)
19. 0.000 0.000 ↓ 0.0

Index Scan using charges_pkey on charges charge (cost=0.44..8.40 rows=1 width=82) (actual rows= loops=)

  • Index Cond: (order_id = o.id)
20. 0.000 0.000 ↓ 0.0

Index Scan using organizations_pkey on organizations service (cost=0.29..1.78 rows=1 width=22) (actual rows= loops=)

  • Index Cond: (party_id = o.service_id)
21. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses pa (cost=0.43..8.30 rows=1 width=237) (actual rows= loops=)

  • Index Cond: (id = o.pickup_address_id)
22. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses da (cost=0.43..8.30 rows=1 width=237) (actual rows= loops=)

  • Index Cond: (id = o.delivery_address_id)
23. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses ra (cost=0.43..8.30 rows=1 width=237) (actual rows= loops=)

  • Index Cond: (id = o.return_address_id)
24. 0.000 0.000 ↓ 0.0

Hash (cost=359.49..359.49 rows=18,149 width=19) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Seq Scan on locations pac (cost=0.00..359.49 rows=18,149 width=19) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash (cost=359.49..359.49 rows=18,149 width=19) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Seq Scan on locations dac (cost=0.00..359.49 rows=18,149 width=19) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Index Scan using locations_pkey on locations rac (cost=0.29..0.68 rows=1 width=19) (actual rows= loops=)

  • Index Cond: (id = ra.country_id)
29. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.72..8.99 rows=1 width=248) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses "do" (cost=0.43..8.30 rows=1 width=237) (actual rows= loops=)

  • Index Cond: (id = o.dropoff_address_id)
31. 0.000 0.000 ↓ 0.0

Index Scan using locations_pkey on locations doc (cost=0.29..0.68 rows=1 width=19) (actual rows= loops=)

  • Index Cond: (id = "do".country_id)
32.          

SubPlan (forNested Loop Left Join)

33. 0.000 0.000 ↓ 0.0

Aggregate (cost=35.26..35.27 rows=1 width=88) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Index Scan using order_items_order_id_idx on order_items i (cost=0.57..34.49 rows=153 width=88) (actual rows= loops=)

  • Index Cond: (order_id = o.id)
35. 0.000 0.000 ↓ 0.0

Index Scan using order_segments_pkey on order_segments active_segment (cost=0.56..8.58 rows=1 width=66) (actual rows= loops=)

  • Index Cond: (id = o.active_segment_id)
36. 0.000 0.000 ↓ 0.0

Aggregate (cost=339.11..339.12 rows=1 width=99) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

Index Scan using orders_parent_id_idx on orders child (cost=0.56..8.58 rows=1 width=99) (actual rows= loops=)

  • Index Cond: (parent_id = o.id)
38.          

SubPlan (forAggregate)

39. 0.000 0.000 ↓ 0.0

Aggregate (cost=264.10..264.11 rows=1 width=51) (actual rows= loops=)

40. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.14..263.59 rows=100 width=51) (actual rows= loops=)

41. 0.000 0.000 ↓ 0.0

Index Scan using order_segments_order_id_idx on order_segments child_segments (cost=0.56..31.01 rows=26 width=4) (actual rows= loops=)

  • Index Cond: (order_id = child.id)
42. 0.000 0.000 ↓ 0.0

Index Scan using order_events_order_segment_id_idx on order_events child_events (cost=0.57..8.87 rows=8 width=55) (actual rows= loops=)

  • Index Cond: (order_segment_id = child_segments.id)
43. 0.000 0.000 ↓ 0.0

Aggregate (cost=35.26..35.27 rows=1 width=96) (actual rows= loops=)

44. 0.000 0.000 ↓ 0.0

Index Scan using order_items_order_id_idx on order_items child_items (cost=0.57..34.49 rows=153 width=96) (actual rows= loops=)

  • Index Cond: (order_id = child.id)
45. 0.000 0.000 ↓ 0.0

Aggregate (cost=31.14..31.15 rows=1 width=22) (actual rows= loops=)

46. 0.000 0.000 ↓ 0.0

Index Scan using order_segments_order_id_idx on order_segments child_segments_1 (cost=0.56..31.01 rows=26 width=22) (actual rows= loops=)

  • Index Cond: (order_id = child.id)
47. 0.000 0.000 ↓ 0.0

Aggregate (cost=912.61..912.62 rows=1 width=1,459) (actual rows= loops=)

48. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.60..912.09 rows=26 width=1,459) (actual rows= loops=)

49. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.31..903.89 rows=26 width=1,448) (actual rows= loops=)

50. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=2.02..895.70 rows=26 width=1,437) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.58..675.67 rows=26 width=1,248) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.15..455.65 rows=26 width=1,059) (actual rows= loops=)

53. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.86..243.33 rows=26 width=117) (actual rows= loops=)

54. 0.000 0.000 ↓ 0.0

Index Scan using order_segments_order_id_idx on order_segments os (cost=0.56..31.01 rows=26 width=99) (actual rows= loops=)

  • Index Cond: (order_id = o.id)
55. 0.000 0.000 ↓ 0.0

Index Scan using organizations_pkey on organizations os_org (cost=0.29..8.16 rows=1 width=22) (actual rows= loops=)

  • Index Cond: (party_id = os.courier_party_id)
56. 0.000 0.000 ↓ 0.0

Index Scan using parties_pkey on parties p (cost=0.29..8.16 rows=1 width=950) (actual rows= loops=)

  • Index Cond: (id = os.courier_party_id)
57. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses os_pa (cost=0.43..8.45 rows=1 width=197) (actual rows= loops=)

  • Index Cond: (id = os.pickup_address_id)
58. 0.000 0.000 ↓ 0.0

Index Scan using addresses_pkey on addresses os_da (cost=0.43..8.45 rows=1 width=197) (actual rows= loops=)

  • Index Cond: (id = os.delivery_address_id)
59. 0.000 0.000 ↓ 0.0

Index Scan using locations_pkey on locations os_pac (cost=0.29..0.31 rows=1 width=19) (actual rows= loops=)

  • Index Cond: (id = os_pa.country_id)
60. 0.000 0.000 ↓ 0.0

Index Scan using locations_pkey on locations os_dac (cost=0.29..0.31 rows=1 width=19) (actual rows= loops=)

  • Index Cond: (id = os_da.country_id)
61. 0.000 0.000 ↓ 0.0

Aggregate (cost=265.46..265.47 rows=1 width=51) (actual rows= loops=)

62.          

CTE ordersegments

63. 0.000 0.000 ↓ 0.0

Index Scan using order_segments_order_id_idx on order_segments os_1 (cost=0.56..31.01 rows=26 width=4) (actual rows= loops=)

  • Index Cond: (order_id = o.id)
64. 0.000 0.000 ↓ 0.0

Nested Loop (cost=1.16..233.43 rows=203 width=51) (actual rows= loops=)

65. 0.000 0.000 ↓ 0.0

HashAggregate (cost=0.58..0.84 rows=26 width=4) (actual rows= loops=)

  • Group Key: ordersegments.id
66. 0.000 0.000 ↓ 0.0

CTE Scan on ordersegments (cost=0.00..0.52 rows=26 width=4) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

Index Scan using order_events_order_segment_id_idx on order_events oe (cost=0.57..8.87 rows=8 width=55) (actual rows= loops=)

  • Index Cond: (order_segment_id = ordersegments.id)