explain.depesz.com

PostgreSQL's explain analyze made readable

Result: qBTw

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

Limit (cost=1,239,638.51..1,243,201.95 rows=1,000 width=1,272) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=1,239,638.51..5,523,267.97 rows=1,202,106 width=1,272) (actual rows= loops=)

  • Merge Cond: (oc.id = hs.order_id)
3. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=398,961.13..4,267,434.94 rows=1,202,106 width=1,282) (actual rows= loops=)

  • Merge Cond: (oc.id = h_state_2.order_id)
  • Join Filter: (oc.driver_id = h_state_2.driver_id)
4. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.69..3,686,925.27 rows=1,202,106 width=1,218) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.56..3,503,795.42 rows=1,202,106 width=1,205) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.42..3,317,695.62 rows=1,202,106 width=1,180) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.28..3,125,517.80 rows=1,202,106 width=1,155) (actual rows= loops=)

  • Join Filter: (dbp.id = oc.billing_type)
8. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.28..3,078,886.77 rows=1,202,106 width=1,144) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.14..2,893,343.69 rows=1,202,106 width=1,105) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=398,960.00..2,635,147.26 rows=1,202,106 width=1,091) (actual rows= loops=)

11. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=398,959.86..2,439,793.31 rows=1,202,106 width=1,093) (actual rows= loops=)

  • Merge Cond: (oc.id = h_state_1.order_id)
12. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=250,080.45..2,185,528.45 rows=1,202,106 width=1,085) (actual rows= loops=)

  • Merge Cond: (oc.id = h_state.order_id)
13. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=53,422.24..1,960,788.74 rows=1,202,106 width=1,077) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=53,421.82..1,396,340.93 rows=1,202,106 width=1,048) (actual rows= loops=)

  • Join Filter: (bp.id = oc.project_id)
15. 0.000 0.000 ↓ 0.0

Merge Left Join (cost=53,416.46..1,107,813.13 rows=1,202,106 width=1,033) (actual rows= loops=)

  • Merge Cond: (oc.id = inc.order_id)
16. 0.000 0.000 ↓ 0.0

Gather Merge (cost=1,001.28..1,044,013.74 rows=1,202,106 width=1,021) (actual rows= loops=)

  • Workers Planned: 2
17. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=1.26..904,260.86 rows=500,878 width=1,021) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.97..751,310.81 rows=500,878 width=980) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=0.70..605,977.71 rows=500,878 width=967) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

Parallel Index Scan using common_pk on common oc (cost=0.43..460,645.25 rows=500,878 width=954) (actual rows= loops=)

21. 0.000 0.000 ↓ 0.0

Index Scan using zones_pk on zones bz_f (cost=0.27..0.29 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (id = oc.route_zone_from_id)
22. 0.000 0.000 ↓ 0.0

Index Scan using zones_pk on zones bz_t (cost=0.27..0.29 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (id = oc.route_zone_to_id)
23. 0.000 0.000 ↓ 0.0

Index Scan using driver_card_uk1 on driver_card dc (cost=0.29..0.31 rows=1 width=45) (actual rows= loops=)

  • Index Cond: (user_id = oc.driver_id)
24. 0.000 0.000 ↓ 0.0

Materialize (cost=52,415.18..60,778.04 rows=1,286 width=16) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Subquery Scan on inc (cost=52,415.18..60,774.83 rows=1,286 width=16) (actual rows= loops=)

  • Filter: (inc.rownum = 1)
26. 0.000 0.000 ↓ 0.0

WindowAgg (cost=52,415.18..57,559.58 rows=257,220 width=28) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Sort (cost=52,415.18..53,058.23 rows=257,220 width=20) (actual rows= loops=)

  • Sort Key: h_payment.order_id, h_payment.id DESC
28. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on h_payment (cost=5,458.31..24,022.56 rows=257,220 width=20) (actual rows= loops=)

  • Recheck Cond: (d_payment_update_type_id = ANY ('{1,2}'::integer[]))
29. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on h_payment_d_payment_update_type_id_idx1 (cost=0.00..5,394.00 rows=257,220 width=0) (actual rows= loops=)

  • Index Cond: (d_payment_update_type_id = ANY ('{1,2}'::integer[]))
30. 0.000 0.000 ↓ 0.0

Materialize (cost=5.36..22.40 rows=16 width=19) (actual rows= loops=)

31. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=5.36..22.32 rows=16 width=19) (actual rows= loops=)

  • Hash Cond: (btz.id = bp.time_zone_id)
32. 0.000 0.000 ↓ 0.0

Seq Scan on d_time_zones btz (cost=0.00..10.90 rows=590 width=19) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Hash (cost=5.16..5.16 rows=16 width=20) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Seq Scan on projects bp (cost=0.00..5.16 rows=16 width=20) (actual rows= loops=)

35. 0.000 0.000 ↓ 0.0

Index Scan using client_info_pk on client_card cc (cost=0.42..0.47 rows=1 width=29) (actual rows= loops=)

  • Index Cond: (user_id = oc.client_id)
36. 0.000 0.000 ↓ 0.0

Materialize (cost=196,658.20..215,297.26 rows=514,975 width=12) (actual rows= loops=)

37. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=196,658.20..208,860.07 rows=514,975 width=16) (actual rows= loops=)

  • Group Key: h_state.state_id, h_state.order_id
38. 0.000 0.000 ↓ 0.0

Sort (cost=196,658.20..198,421.23 rows=705,212 width=16) (actual rows= loops=)

  • Sort Key: h_state.order_id
39. 0.000 0.000 ↓ 0.0

Bitmap Heap Scan on h_state (cost=16,765.83..116,100.98 rows=705,212 width=16) (actual rows= loops=)

  • Filter: (state_id = 203)
40. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on h_state_expr_idx (cost=0.00..16,589.52 rows=705,212 width=0) (actual rows= loops=)

  • Index Cond: ((state_id = 203) = true)
41. 0.000 0.000 ↓ 0.0

Materialize (cost=148,879.41..244,523.66 rows=538,874 width=12) (actual rows= loops=)

42. 0.000 0.000 ↓ 0.0

Finalize GroupAggregate (cost=148,879.41..237,787.74 rows=538,874 width=16) (actual rows= loops=)

  • Group Key: h_state_1.state_id, h_state_1.order_id
43. 0.000 0.000 ↓ 0.0

Gather Merge (cost=148,879.41..227,686.58 rows=628,322 width=16) (actual rows= loops=)

  • Workers Planned: 2
44. 0.000 0.000 ↓ 0.0

Partial GroupAggregate (cost=147,879.39..154,162.61 rows=314,161 width=16) (actual rows= loops=)

  • Group Key: h_state_1.state_id, h_state_1.order_id
45. 0.000 0.000 ↓ 0.0

Sort (cost=147,879.39..148,664.79 rows=314,161 width=16) (actual rows= loops=)

  • Sort Key: h_state_1.order_id
46. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on h_state h_state_1 (cost=0.00..113,825.69 rows=314,161 width=16) (actual rows= loops=)

  • Filter: (state_id = 202)
47. 0.000 0.000 ↓ 0.0

Index Scan using clients_pk on clients cont (cost=0.14..0.16 rows=1 width=6) (actual rows= loops=)

  • Index Cond: (client_id = oc.client_id)
48. 0.000 0.000 ↓ 0.0

Index Scan using company_card_pkey on company_card comp (cost=0.14..0.22 rows=1 width=18) (actual rows= loops=)

  • Index Cond: (cont.company_id = id)
49. 0.000 0.000 ↓ 0.0

Index Scan using d_states_pk on d_states dst (cost=0.14..0.16 rows=1 width=41) (actual rows= loops=)

  • Index Cond: (id = oc.state_id)
50. 0.000 0.000 ↓ 0.0

Materialize (cost=0.00..1.04 rows=3 width=15) (actual rows= loops=)

51. 0.000 0.000 ↓ 0.0

Seq Scan on d_billing_types dbp (cost=0.00..1.03 rows=3 width=15) (actual rows= loops=)

52. 0.000 0.000 ↓ 0.0

Index Scan using d_tariffs_pk on d_tariffs dt (cost=0.14..0.16 rows=1 width=29) (actual rows= loops=)

  • Index Cond: (id = oc.billing_id)
53. 0.000 0.000 ↓ 0.0

Index Scan using d_packages_pk on d_packages dp (cost=0.14..0.16 rows=1 width=29) (actual rows= loops=)

  • Index Cond: (id = oc.billing_id)
54. 0.000 0.000 ↓ 0.0

Index Scan using d_sessions_pk on d_sessions ds (cost=0.14..0.15 rows=1 width=21) (actual rows= loops=)

  • Index Cond: (id = oc.billing_id)
55. 0.000 0.000 ↓ 0.0

Materialize (cost=0.43..564,102.41 rows=893,466 width=72) (actual rows= loops=)

56. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=0.43..552,934.09 rows=893,466 width=72) (actual rows= loops=)

  • Group Key: h_state_2.order_id, h_state_2.driver_id
57. 0.000 0.000 ↓ 0.0

Index Scan using h_state_order_id_driver_id_idx on h_state h_state_2 (cost=0.43..373,983.18 rows=4,474,693 width=20) (actual rows= loops=)

58. 0.000 0.000 ↓ 0.0

GroupAggregate (cost=840,677.39..937,088.47 rows=809,692 width=36) (actual rows= loops=)

  • Group Key: hs.order_id
59. 0.000 0.000 ↓ 0.0

Sort (cost=840,677.39..844,890.67 rows=1,685,314 width=82) (actual rows= loops=)

  • Sort Key: hs.order_id
60. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=242,755.18..505,083.27 rows=1,685,314 width=82) (actual rows= loops=)

  • Hash Cond: (hs.took_off_reason = tr.id)
61. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=242,754.06..483,846.25 rows=1,685,314 width=56) (actual rows= loops=)

  • Hash Cond: (hs.driver_id = dc_1.user_id)
62. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=241,649.91..461,465.72 rows=1,685,314 width=44) (actual rows= loops=)

  • Hash Cond: (oc_1.project_id = bp_1.id)
63. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=241,627.39..438,270.13 rows=1,685,314 width=33) (actual rows= loops=)

  • Hash Cond: (hs.order_id = oc_1.id)
64. 0.000 0.000 ↓ 0.0

Seq Scan on h_state hs (cost=0.00..146,453.66 rows=1,685,314 width=29) (actual rows= loops=)

  • Filter: ((driver_id IS NOT NULL) AND ((state_id = ANY ('{201,102}'::integer[])) OR (operator_id IS NOT NULL)))
65. 0.000 0.000 ↓ 0.0

Hash (cost=220,731.06..220,731.06 rows=1,202,106 width=12) (actual rows= loops=)

66. 0.000 0.000 ↓ 0.0

Seq Scan on common oc_1 (cost=0.00..220,731.06 rows=1,202,106 width=12) (actual rows= loops=)

67. 0.000 0.000 ↓ 0.0

Hash (cost=22.32..22.32 rows=16 width=19) (actual rows= loops=)

68. 0.000 0.000 ↓ 0.0

Hash Right Join (cost=5.36..22.32 rows=16 width=19) (actual rows= loops=)

  • Hash Cond: (btz_1.id = bp_1.time_zone_id)
69. 0.000 0.000 ↓ 0.0

Seq Scan on d_time_zones btz_1 (cost=0.00..10.90 rows=590 width=19) (actual rows= loops=)

70. 0.000 0.000 ↓ 0.0

Hash (cost=5.16..5.16 rows=16 width=20) (actual rows= loops=)

71. 0.000 0.000 ↓ 0.0

Seq Scan on projects bp_1 (cost=0.00..5.16 rows=16 width=20) (actual rows= loops=)

72. 0.000 0.000 ↓ 0.0

Hash (cost=919.07..919.07 rows=14,807 width=16) (actual rows= loops=)

73. 0.000 0.000 ↓ 0.0

Seq Scan on driver_card dc_1 (cost=0.00..919.07 rows=14,807 width=16) (actual rows= loops=)

74. 0.000 0.000 ↓ 0.0

Hash (cost=1.05..1.05 rows=5 width=34) (actual rows= loops=)

75. 0.000 0.000 ↓ 0.0

Seq Scan on d_tookoff_reasons tr (cost=0.00..1.05 rows=5 width=34) (actual rows= loops=)