explain.depesz.com

PostgreSQL's explain analyze made readable

Result: a2RUa

Settings
# exclusive inclusive rows x rows loops node
1. 0.001 12,838.682 ↓ 0.0 0 1

Limit (cost=586,622.04..586,623.79 rows=25 width=1,775) (actual time=12,838.682..12,838.682 rows=0 loops=1)

2. 0.000 12,838.681 ↓ 0.0 0 1

Unique (cost=586,622.04..586,717.66 rows=1,366 width=1,775) (actual time=12,838.681..12,838.681 rows=0 loops=1)

3. 0.020 12,838.681 ↓ 0.0 0 1

Sort (cost=586,622.04..586,625.45 rows=1,366 width=1,775) (actual time=12,838.681..12,838.681 rows=0 loops=1)

  • Sort Key: (CASE WHEN ((road_card_item.verified = ANY ('{0,3}'::integer[])) AND (road_card_item.confirm_comment IS NULL)) THEN 0 ELSE 1 END), road_card_day.road_card_day_date, (to_char((road_card_item.veh_work_from)::interval, 'HH24:MI:SS'::text)), road_card.rc_number, (CASE WHEN (pojazd.pokazuj_nr_rejestracyjny = 1) THEN pojazd.nr_rejestracyjny ELSE ''::character varying END), road_card_item.verified, road_card_item.verified_driver, road_card_item.road_card_day_id, road_card_item.road_card_item_id, road_card_item.kierowca_id, road_card_item.counter_from, road_card_item.counter_to, (to_char((road_card_item.veh_work_to)::interval, 'HH24:MI:SS'::text)), road_card_item.dist_all, (CASE WHEN (road_card_item.work_destination_id > 0) THEN firma_cel_wyjazdu.nazwa ELSE road_card_item.work_destination_text END), ((((kierowca.imie)::text || ' '::text) || (kierowca.nazwisko)::text)), kierowca_organizacja.wymaga_akcept, kierowca_organizacja.wymaga_akcept_pojazd, kierowca_organizacja.superior_id, auser.superior_alternate_akt, auser.superior_alternate_id, (CASE WHEN ((road_card_item.verified = 0) AND (road_card_item.confirm_comment IS NOT NULL)) THEN (-1) WHEN (road_card_item.verified = 2) THEN 1 ELSE 0 END), (CASE WHEN ((road_card.is_detailed_records = 0) OR (road_card_item.verified_driver = 1)) THEN (-9999) WHEN ((road_card_item.verified_driver = 0) AND (road_card_item.verified_driver_comment IS NOT NULL)) THEN (-1) WHEN (road_card_item.verified_driver = 2) THEN 1 ELSE 0 END), road_card.is_detailed_records, (CASE WHEN ((road_card.is_detailed_records = 1) AND (road_card_item.verified_driver <> 1) AND (kierowca.auser_id = 1)) THEN 1 ELSE 0 END), ((((COALESCE(auser.surname, ''::character varying))::text || ' '::text) || (COALESCE(auser.name, ''::character varying))::text)), superior_structure.name
  • Sort Method: quicksort Memory: 25kB
4. 0.001 12,838.661 ↓ 0.0 0 1

Nested Loop Semi Join (cost=176,529.55..586,550.90 rows=1,366 width=1,775) (actual time=12,838.661..12,838.661 rows=0 loops=1)

5. 0.000 12,838.660 ↓ 0.0 0 1

Nested Loop Left Join (cost=176,529.26..586,047.57 rows=1,366 width=1,779) (actual time=12,838.660..12,838.660 rows=0 loops=1)

6. 0.001 12,838.660 ↓ 0.0 0 1

Nested Loop Left Join (cost=176,529.12..585,811.92 rows=1,366 width=1,263) (actual time=12,838.660..12,838.660 rows=0 loops=1)

7. 0.001 12,838.659 ↓ 0.0 0 1

Nested Loop Left Join (cost=176,528.84..585,393.06 rows=1,366 width=1,241) (actual time=12,838.659..12,838.659 rows=0 loops=1)

8. 0.001 12,838.658 ↓ 0.0 0 1

Nested Loop Left Join (cost=176,528.55..584,821.33 rows=1,366 width=1,241) (actual time=12,838.658..12,838.658 rows=0 loops=1)

9. 20.260 12,838.657 ↓ 0.0 0 1

Hash Left Join (cost=176,528.26..583,803.28 rows=1,366 width=1,241) (actual time=12,838.657..12,838.657 rows=0 loops=1)

  • Hash Cond: (road_card_item.road_card_timestamp_id = road_card_timestamps.road_card_timestamp_id)
  • Filter: (((kierowca_organizacja.wymaga_akcept = 1) AND ((CASE WHEN ((1 = kierowca_organizacja.superior_id) OR (1 = kierowca_organizacja.superior2_id) OR (1 = kierowca_organizacja.superior3_id) OR (1 = kierowca_organizacja.superior4_id) OR (1 = kierowca_organizacja.superior5_id) OR (1 = kierowca_organizacja.superior6_id) OR (1 = kierowca_organizacja.superior7_id) OR (1 = kierowca_organizacja.superior8_id)) THEN 1 ELSE 0 END = 1) OR (CASE WHEN ((auser.superior_alternate_akt = 1) AND (auser.superior_alternate_id = 1)) THEN 1 ELSE 0 END = 1) OR (CASE WHEN ((road_card_item.road_card_timestamp_id IS NOT NULL) AND ((road_card_timestamps.account)::text = '-1'::text)) THEN 1 ELSE 0 END = 1) OR (CASE WHEN ((road_card.is_detailed_records = 1) AND (road_card_item.verified_driver <> 1) AND (kierowca.auser_id = 1)) THEN 1 ELSE 0 END = 1))) OR (CASE WHEN ((kierowca_organizacja.wymaga_akcept_pojazd = 1) AND (pojazd_zatwierdzanie_jazd.auser_id = 1)) THEN 1 ELSE 0 END = 1))
  • Rows Removed by Filter: 54069
10. 11.894 12,818.397 ↑ 3.6 54,069 1

Hash Left Join (cost=176,515.34..583,054.63 rows=196,175 width=1,277) (actual time=11,610.221..12,818.397 rows=54,069 loops=1)

  • Hash Cond: (pojazd.pojazd_id = pojazd_zatwierdzanie_jazd.pojazd_id)
11. 52.662 12,806.502 ↑ 3.6 54,069 1

Hash Join (cost=176,465.51..538,875.16 rows=196,175 width=1,277) (actual time=11,610.202..12,806.502 rows=54,069 loops=1)

  • Hash Cond: (road_card_item.kierowca_id = kierowca.kierowca_id)
12. 27.226 12,639.144 ↑ 3.6 55,368 1

Hash Join (cost=169,729.99..529,432.79 rows=198,692 width=1,197) (actual time=11,495.481..12,639.144 rows=55,368 loops=1)

  • Hash Cond: (road_card.pojazd_id = pojazd.pojazd_id)
13. 6,962.978 12,602.402 ↑ 3.6 55,368 1

Hash Join (cost=168,328.82..525,299.61 rows=198,692 width=1,187) (actual time=11,485.945..12,602.402 rows=55,368 loops=1)

  • Hash Cond: (road_card_item.road_card_day_id = road_card_day.road_card_day_id)
  • Join Filter: (((((road_card_day.road_card_day_date)::text || ' '::text) || to_char((road_card_item.veh_work_from)::interval, 'HH24:MI:SS'::text)) >= '2019-06-01 00:00'::text) AND ((((road_card_day.road_card_day_date)::text || ' '::text) || to_char((road_card_item.veh_work_to)::interval, 'HH24:MI:SS'::text)) <= '2019-07-09 23:59'::text))
  • Rows Removed by Join Filter: 1982537
14. 2,702.658 2,702.658 ↑ 1.0 3,851,912 1

Seq Scan on road_card_item (cost=0.00..251,597.70 rows=3,984,431 width=1,163) (actual time=0.011..2,702.658 rows=3,851,912 loops=1)

  • Filter: ((verified = 0) OR ((verified = ANY ('{2,3}'::integer[])) AND (kierowca_id > 0)) OR (verified_driver = 0) OR ((verified_driver = ANY ('{2,3}'::integer[])) AND (kierowca_id > 0)))
  • Rows Removed by Filter: 26836
15. 499.514 2,936.766 ↓ 1.2 1,810,302 1

Hash (cost=148,831.37..148,831.37 rows=1,559,796 width=28) (actual time=2,936.766..2,936.766 rows=1,810,302 loops=1)

  • Buckets: 262144 Batches: 1 Memory Usage: 113144kB
16. 1,831.369 2,437.252 ↓ 1.2 1,810,302 1

Hash Join (cost=26,356.18..148,831.37 rows=1,559,796 width=28) (actual time=987.872..2,437.252 rows=1,810,302 loops=1)

  • Hash Cond: (road_card_day.road_card_id = road_card.road_card_id)
17. 389.757 389.757 ↑ 1.0 3,459,553 1

Seq Scan on road_card_day (cost=0.00..63,547.10 rows=3,466,410 width=12) (actual time=0.020..389.757 rows=3,459,553 loops=1)

18. 50.565 216.126 ↑ 1.0 248,000 1

Hash (cost=23,174.12..23,174.12 rows=254,565 width=24) (actual time=216.126..216.126 rows=248,000 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 14532kB
19. 165.561 165.561 ↑ 1.0 248,000 1

Seq Scan on road_card (cost=0.00..23,174.12 rows=254,565 width=24) (actual time=41.365..165.561 rows=248,000 loops=1)

  • Filter: ((rc_add >= '2016-10-01 00:00:00'::timestamp without time zone) AND (gps_load = 1))
  • Rows Removed by Filter: 292286
20. 1.450 9.516 ↑ 1.7 8,639 1

Hash (cost=1,216.86..1,216.86 rows=14,745 width=14) (actual time=9.516..9.516 rows=8,639 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 410kB
21. 2.910 8.066 ↑ 1.7 8,639 1

Hash Right Join (cost=657.76..1,216.86 rows=14,745 width=14) (actual time=3.385..8.066 rows=8,639 loops=1)

  • Hash Cond: (pojazd_organizacja.pojazd_id = pojazd.pojazd_id)
22. 1.792 1.792 ↑ 1.0 9,347 1

Seq Scan on pojazd_organizacja (cost=0.00..360.47 rows=9,347 width=8) (actual time=0.005..1.792 rows=9,347 loops=1)

23. 1.428 3.364 ↑ 1.7 8,639 1

Hash (cost=473.45..473.45 rows=14,745 width=14) (actual time=3.364..3.364 rows=8,639 loops=1)

  • Buckets: 2048 Batches: 1 Memory Usage: 410kB
24. 1.936 1.936 ↑ 1.7 8,639 1

Seq Scan on pojazd (cost=0.00..473.45 rows=14,745 width=14) (actual time=0.005..1.936 rows=8,639 loops=1)

25. 15.095 114.696 ↓ 1.0 54,475 1

Hash (cost=6,054.65..6,054.65 rows=54,470 width=92) (actual time=114.696..114.696 rows=54,475 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 4311kB
26. 12.262 99.601 ↓ 1.0 54,475 1

Hash Left Join (cost=2,325.78..6,054.65 rows=54,470 width=92) (actual time=24.740..99.601 rows=54,475 loops=1)

  • Hash Cond: (kierowca_organizacja.superior_id = auser.auser_id)
27. 36.732 83.769 ↓ 1.0 54,475 1

Hash Join (cost=1,864.58..4,830.62 rows=54,470 width=67) (actual time=21.157..83.769 rows=54,475 loops=1)

  • Hash Cond: (kierowca_organizacja.kierowca_id = kierowca.kierowca_id)
28. 25.910 25.910 ↑ 1.0 55,534 1

Seq Scan on kierowca_organizacja (cost=0.00..1,786.40 rows=56,440 width=44) (actual time=0.005..25.910 rows=55,534 loops=1)

29. 9.454 21.127 ↓ 1.0 54,475 1

Hash (cost=1,183.70..1,183.70 rows=54,470 width=23) (actual time=21.127..21.127 rows=54,475 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 2778kB
30. 11.673 11.673 ↓ 1.0 54,475 1

Seq Scan on kierowca (cost=0.00..1,183.70 rows=54,470 width=23) (actual time=0.004..11.673 rows=54,475 loops=1)

31. 1.168 3.570 ↑ 1.1 6,863 1

Hash (cost=368.87..368.87 rows=7,387 width=25) (actual time=3.570..3.570 rows=6,863 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 366kB
32. 2.402 2.402 ↑ 1.1 6,863 1

Seq Scan on auser (cost=0.00..368.87 rows=7,387 width=25) (actual time=0.005..2.402 rows=6,863 loops=1)

33. 0.000 0.001 ↓ 0.0 0 1

Hash (cost=27.70..27.70 rows=1,770 width=8) (actual time=0.001..0.001 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 0kB
34. 0.001 0.001 ↓ 0.0 0 1

Seq Scan on pojazd_zatwierdzanie_jazd (cost=0.00..27.70 rows=1,770 width=8) (actual time=0.001..0.001 rows=0 loops=1)

35. 0.000 0.000 ↓ 0.0 0 1

Hash (cost=11.30..11.30 rows=130 width=520) (actual time=0.000..0.000 rows=0 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 0kB
36. 0.000 0.000 ↓ 0.0 0 1

Seq Scan on road_card_timestamps (cost=0.00..11.30 rows=130 width=520) (actual time=0.000..0.000 rows=0 loops=1)

37. 0.000 0.000 ↓ 0.0 0

Index Scan using kierowca_auser_id on kierowca superior_driver (cost=0.29..0.74 rows=1 width=8) (never executed)

  • Index Cond: (auser_id = auser.auser_id)
38. 0.000 0.000 ↓ 0.0 0

Index Scan using kierowca_organizacja_index01 on kierowca_organizacja superior_details (cost=0.29..0.41 rows=1 width=12) (never executed)

  • Index Cond: (kierowca_id = superior_driver.kierowca_id)
39. 0.000 0.000 ↓ 0.0 0

Index Scan using firma_struktura_pkey on firma_struktura superior_structure (cost=0.28..0.30 rows=1 width=30) (never executed)

  • Index Cond: (firma_struktura_id = superior_details.company_structure_id)
40. 0.000 0.000 ↓ 0.0 0

Index Scan using firma_cel_wyjazdu_pkey on firma_cel_wyjazdu (cost=0.14..0.16 rows=1 width=520) (never executed)

  • Index Cond: (firma_cel_wyjazdu_id = road_card_item.work_destination_id)
41. 0.000 0.000 ↓ 0.0 0

Index Only Scan using auser_firma_index01 on auser_firma (cost=0.29..0.31 rows=1 width=4) (never executed)

  • Index Cond: ((auser_id = 1) AND (firma1_id = road_card.firma1_id))
  • Heap Fetches: 0
Planning time : 29.361 ms
Execution time : 12,839.077 ms