explain.depesz.com

PostgreSQL's explain analyze made readable

Result: F7YK

Settings
# exclusive inclusive rows x rows loops node
1. 0.001 14,239.153 ↓ 0.0 0 1

Limit (cost=743,003.73..743,005.48 rows=25 width=1,775) (actual time=14,239.153..14,239.153 rows=0 loops=1)

2. 0.001 14,239.152 ↓ 0.0 0 1

Unique (cost=743,003.73..743,201.48 rows=2,825 width=1,775) (actual time=14,239.152..14,239.152 rows=0 loops=1)

3. 0.033 14,239.151 ↓ 0.0 0 1

Sort (cost=743,003.73..743,010.79 rows=2,825 width=1,775) (actual time=14,239.151..14,239.151 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.002 14,239.118 ↓ 0.0 0 1

Nested Loop Semi Join (cost=142,656.78..742,841.80 rows=2,825 width=1,775) (actual time=14,239.118..14,239.118 rows=0 loops=1)

5. 0.000 14,239.116 ↓ 0.0 0 1

Nested Loop Left Join (cost=142,656.49..741,803.76 rows=2,825 width=1,779) (actual time=14,239.116..14,239.116 rows=0 loops=1)

6. 0.001 14,239.116 ↓ 0.0 0 1

Nested Loop Left Join (cost=142,656.35..741,316.41 rows=2,825 width=1,263) (actual time=14,239.116..14,239.116 rows=0 loops=1)

7. 0.000 14,239.115 ↓ 0.0 0 1

Nested Loop Left Join (cost=142,656.07..740,450.18 rows=2,825 width=1,241) (actual time=14,239.115..14,239.115 rows=0 loops=1)

8. 0.001 14,239.115 ↓ 0.0 0 1

Nested Loop Left Join (cost=142,655.78..739,267.79 rows=2,825 width=1,241) (actual time=14,239.115..14,239.115 rows=0 loops=1)

9. 21.495 14,239.114 ↓ 0.0 0 1

Hash Left Join (cost=142,655.49..737,162.38 rows=2,825 width=1,241) (actual time=14,239.114..14,239.114 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. 12.422 14,217.618 ↑ 7.5 54,069 1

Hash Left Join (cost=142,642.56..735,628.27 rows=405,632 width=1,277) (actual time=12,830.625..14,217.618 rows=54,069 loops=1)

  • Hash Cond: (pojazd.pojazd_id = pojazd_zatwierdzanie_jazd.pojazd_id)
11. 28.466 14,205.196 ↑ 7.5 54,069 1

Hash Left Join (cost=142,592.74..644,331.36 rows=405,632 width=1,277) (actual time=12,830.614..14,205.196 rows=54,069 loops=1)

  • Hash Cond: (kierowca_organizacja.superior_id = auser.auser_id)
12. 28.622 14,172.844 ↑ 7.5 54,069 1

Hash Join (cost=142,131.53..638,189.54 rows=405,632 width=1,252) (actual time=12,826.709..14,172.844 rows=54,069 loops=1)

  • Hash Cond: (road_card.pojazd_id = pojazd.pojazd_id)
13. 50.804 14,134.520 ↑ 7.5 54,069 1

Hash Join (cost=140,730.36..631,210.94 rows=405,632 width=1,242) (actual time=12,816.992..14,134.520 rows=54,069 loops=1)

  • Hash Cond: (road_card_item.kierowca_id = kierowca.kierowca_id)
14. 49.904 13,984.086 ↑ 7.4 55,368 1

Hash Join (cost=135,218.86..620,102.49 rows=410,835 width=1,187) (actual time=12,717.322..13,984.086 rows=55,368 loops=1)

  • Hash Cond: (road_card_day.road_card_id = road_card.road_card_id)
15. 9,477.708 13,602.233 ↑ 7.9 55,866 1

Hash Join (cost=106,877.23..582,132.97 rows=441,563 width=1,171) (actual time=12,385.168..13,602.233 rows=55,866 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: 3786769
16. 2,819.305 2,819.305 ↑ 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.012..2,819.305 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
17. 823.094 1,305.220 ↑ 1.0 3,459,553 1

Hash (cost=63,547.10..63,547.10 rows=3,466,410 width=12) (actual time=1,305.220..1,305.220 rows=3,459,553 loops=1)

  • Buckets: 524288 Batches: 1 Memory Usage: 148630kB
18. 482.126 482.126 ↑ 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.006..482.126 rows=3,459,553 loops=1)

19. 114.525 331.949 ↑ 1.0 502,715 1

Hash (cost=21,762.10..21,762.10 rows=526,363 width=24) (actual time=331.949..331.949 rows=502,715 loops=1)

  • Buckets: 65536 Batches: 1 Memory Usage: 29456kB
20. 217.424 217.424 ↑ 1.0 502,715 1

Seq Scan on road_card (cost=0.00..21,762.10 rows=526,363 width=24) (actual time=0.009..217.424 rows=502,715 loops=1)

  • Filter: (gps_load = 1)
  • Rows Removed by Filter: 37571
21. 14.949 99.630 ↓ 1.0 54,475 1

Hash (cost=4,830.62..4,830.62 rows=54,470 width=67) (actual time=99.630..99.630 rows=54,475 loops=1)

  • Buckets: 8192 Batches: 1 Memory Usage: 4036kB
22. 38.898 84.681 ↓ 1.0 54,475 1

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

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

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

24. 9.733 21.362 ↓ 1.0 54,475 1

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

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

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

26. 1.425 9.702 ↑ 1.7 8,639 1

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

  • Buckets: 2048 Batches: 1 Memory Usage: 410kB
27. 2.940 8.277 ↑ 1.7 8,639 1

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

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

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

29. 1.362 3.411 ↑ 1.7 8,639 1

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

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

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

31. 1.486 3.886 ↑ 1.1 6,863 1

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

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

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

33. 0.000 0.000 ↓ 0.0 0 1

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

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

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

35. 0.001 0.001 ↓ 0.0 0 1

Hash (cost=11.30..11.30 rows=130 width=520) (actual time=0.001..0.001 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 : 27.251 ms
Execution time : 14,239.594 ms