explain.depesz.com

PostgreSQL's explain analyze made readable

Result: j6hr : Optimization for: plan #RzPc

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 1.584 47.887 ↓ 11.4 2,271 1

Hash Left Join (cost=28,858.97..29,899.93 rows=200 width=181) (actual time=29.267..47.887 rows=2,271 loops=1)

  • Hash Cond: (COALESCE(tagtrackingmessagesindexed.ttmi_nl_fixed_id, trackingmessagesindexed.tmi_nl_fixed_id) = nlf.nl_id)
2. 2.318 42.224 ↓ 11.4 2,271 1

Nested Loop Left Join (cost=28,556.00..29,593.94 rows=200 width=124) (actual time=25.065..42.224 rows=2,271 loops=1)

3. 2.536 39.906 ↓ 11.4 2,271 1

Nested Loop Left Join (cost=28,555.71..29,428.61 rows=200 width=112) (actual time=25.062..39.906 rows=2,271 loops=1)

4. 0.684 26.015 ↓ 11.4 2,271 1

Unique (cost=28,555.29..28,596.14 rows=200 width=104) (actual time=25.039..26.015 rows=2,271 loops=1)

5. 1.208 25.331 ↑ 3.6 2,291 1

Sort (cost=28,555.29..28,575.71 rows=8,170 width=104) (actual time=25.038..25.331 rows=2,291 loops=1)

  • Sort Key: o.mobile_device_id
  • Sort Method: quicksort Memory: 276kB
6. 0.334 24.123 ↑ 3.6 2,291 1

Subquery Scan on o (cost=27,922.27..28,024.39 rows=8,170 width=104) (actual time=23.657..24.123 rows=2,291 loops=1)

7. 0.636 23.789 ↑ 3.6 2,291 1

Sort (cost=27,922.27..27,942.69 rows=8,170 width=108) (actual time=23.656..23.789 rows=2,291 loops=1)

  • Sort Key: (CASE WHEN (u.e_et_code = 'TAG'::text) THEN 1 ELSE NULL::integer END)
  • Sort Method: quicksort Memory: 276kB
8. 0.352 23.153 ↑ 3.6 2,291 1

Subquery Scan on u (cost=27,207.55..27,391.38 rows=8,170 width=108) (actual time=22.204..23.153 rows=2,291 loops=1)

9. 1.433 22.801 ↑ 3.6 2,291 1

HashAggregate (cost=27,207.55..27,289.25 rows=8,170 width=104) (actual time=22.203..22.801 rows=2,291 loops=1)

  • Group Key: nodeslogical.nl_id, tagdeviceshistory.tdh_nl_lamp_id, nodeslogical.nl_label, nodeslogical.nl_details, entities.e_et_code
10. 0.193 21.368 ↑ 3.6 2,291 1

Append (cost=250.05..27,105.43 rows=8,170 width=104) (actual time=2.530..21.368 rows=2,291 loops=1)

11. 0.007 16.128 ↑ 248.7 24 1

Result (cost=250.05..26,539.76 rows=5,968 width=40) (actual time=2.529..16.128 rows=24 loops=1)

  • One-Time Filter: $0
12.          

Initplan (for Result)

13. 0.016 0.016 ↑ 1.0 1 1

Seq Scan on serveradmin (cost=0.00..1.46 rows=1 width=0) (actual time=0.016..0.016 rows=1 loops=1)

  • Filter: (((sa_key)::text = 'enableRFID'::text) AND ((sa_value)::text = '1'::text))
  • Rows Removed by Filter: 20
14. 3.870 16.105 ↑ 248.7 24 1

Nested Loop (cost=248.59..26,538.30 rows=5,968 width=40) (actual time=2.511..16.105 rows=24 loops=1)

15. 2.823 6.080 ↓ 1.0 6,155 1

Hash Join (cost=244.24..458.14 rows=5,968 width=36) (actual time=2.432..6.080 rows=6,155 loops=1)

  • Hash Cond: (nodeslogical.nl_e_id = entities.e_id)
16. 0.859 0.859 ↑ 1.0 9,021 1

Seq Scan on nodeslogical (cost=0.00..190.21 rows=9,021 width=37) (actual time=0.007..0.859 rows=9,021 loops=1)

17. 0.922 2.398 ↑ 1.0 6,155 1

Hash (cost=167.30..167.30 rows=6,155 width=7) (actual time=2.398..2.398 rows=6,155 loops=1)

  • Buckets: 8,192 Batches: 1 Memory Usage: 305kB
18. 1.476 1.476 ↑ 1.0 6,155 1

Seq Scan on entities (cost=0.00..167.30 rows=6,155 width=7) (actual time=0.021..1.476 rows=6,155 loops=1)

  • Filter: (e_et_code = 'TAG'::text)
  • Rows Removed by Filter: 3,149
19. 0.000 6.155 ↓ 0.0 0 6,155

Limit (cost=4.35..4.35 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=6,155)

20. 0.000 6.155 ↓ 0.0 0 6,155

Sort (cost=4.35..4.37 rows=9 width=8) (actual time=0.001..0.001 rows=0 loops=6,155)

  • Sort Key: tagdeviceshistory.tdh_date_start DESC
  • Sort Method: top-N heapsort Memory: 25kB
21. 6.155 6.155 ↓ 0.0 0 6,155

Index Only Scan using tagdeviceshistory_pkey on tagdeviceshistory (cost=0.14..4.30 rows=9 width=8) (actual time=0.001..0.001 rows=0 loops=6,155)

  • Index Cond: (tdh_nl_personnel_id = nodeslogical.nl_id)
  • Heap Fetches: 0
22. 0.375 5.047 ↓ 1.0 2,267 1

Hash Anti Join (cost=201.41..443.11 rows=2,202 width=40) (actual time=1.975..5.047 rows=2,267 loops=1)

  • Hash Cond: (nodeslogical_1.nl_id = tagdeviceshistory_1.tdh_nl_lamp_id)
  • Join Filter: $2
23.          

Initplan (for Hash Anti Join)

24. 0.015 0.015 ↑ 1.0 1 1

Seq Scan on serveradmin serveradmin_1 (cost=0.00..1.46 rows=1 width=0) (actual time=0.015..0.015 rows=1 loops=1)

  • Filter: (((sa_key)::text = 'enableRFID'::text) AND ((sa_value)::text = '1'::text))
  • Rows Removed by Filter: 20
25. 1.759 4.626 ↓ 1.0 2,271 1

Hash Join (cost=195.69..409.59 rows=2,202 width=36) (actual time=1.938..4.626 rows=2,271 loops=1)

  • Hash Cond: (nodeslogical_1.nl_e_id = entities_1.e_id)
26. 0.949 0.949 ↑ 1.0 9,021 1

Seq Scan on nodeslogical nodeslogical_1 (cost=0.00..190.21 rows=9,021 width=37) (actual time=0.008..0.949 rows=9,021 loops=1)

27. 0.365 1.918 ↑ 1.0 2,271 1

Hash (cost=167.30..167.30 rows=2,271 width=7) (actual time=1.918..1.918 rows=2,271 loops=1)

  • Buckets: 4,096 Batches: 1 Memory Usage: 122kB
28. 1.553 1.553 ↑ 1.0 2,271 1

Seq Scan on entities entities_1 (cost=0.00..167.30 rows=2,271 width=7) (actual time=0.009..1.553 rows=2,271 loops=1)

  • Filter: (e_et_code = ANY ('{PSD,VMTR}'::text[]))
  • Rows Removed by Filter: 7,033
29. 0.003 0.031 ↑ 1.0 4 1

Hash (cost=4.21..4.21 rows=4 width=4) (actual time=0.031..0.031 rows=4 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 9kB
30. 0.028 0.028 ↑ 1.0 4 1

Seq Scan on tagdeviceshistory tagdeviceshistory_1 (cost=0.00..4.21 rows=4 width=4) (actual time=0.016..0.028 rows=4 loops=1)

  • Filter: (tdh_date_end IS NULL)
  • Rows Removed by Filter: 217
31. 0.000 11.355 ↑ 1.0 1 2,271

Limit (cost=0.42..4.13 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=2,271)

32. 2.303 11.355 ↑ 835.0 1 2,271

Result (cost=0.42..3,096.07 rows=835 width=12) (actual time=0.005..0.005 rows=1 loops=2,271)

  • One-Time Filter: (o.e_et_code = ANY ('{PSD,VMTR}'::text[]))
33. 9.052 9.052 ↑ 835.0 1 2,263

Index Scan using tmi_indextrackingmobile on trackingmessagesindexed (cost=0.42..3,096.07 rows=835 width=12) (actual time=0.004..0.004 rows=1 loops=2,263)

  • Index Cond: (tmi_nl_mobile_id = o.mobile_device_id)
34. 0.000 0.000 ↓ 0.0 0 2,271

Limit (cost=0.29..0.81 rows=1 width=12) (actual time=0.000..0.000 rows=0 loops=2,271)

35. 0.000 0.000 ↓ 0.0 0 2,271

Result (cost=0.29..274.15 rows=525 width=12) (actual time=0.000..0.000 rows=0 loops=2,271)

  • One-Time Filter: (o.e_et_code = 'TAG'::text)
36. 0.096 0.096 ↑ 525.0 1 8

Index Scan Backward using tagtrackingmessagesindexed_pkey on tagtrackingmessagesindexed (cost=0.29..274.15 rows=525 width=12) (actual time=0.012..0.012 rows=1 loops=8)

  • Index Cond: ((ttmi_nl_personnel_id = o.mobile_details_id) AND (ttmi_te_code = 'TRACKING'::text))
37. 2.200 4.079 ↑ 1.0 9,021 1

Hash (cost=190.21..190.21 rows=9,021 width=33) (actual time=4.079..4.079 rows=9,021 loops=1)

  • Buckets: 16,384 Batches: 1 Memory Usage: 569kB
38. 1.879 1.879 ↑ 1.0 9,021 1

Seq Scan on nodeslogical nlf (cost=0.00..190.21 rows=9,021 width=33) (actual time=0.009..1.879 rows=9,021 loops=1)