explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Vrq7 : aws

Settings
# exclusive inclusive rows x rows loops node
1. 0.122 1,064.047 ↑ 1.0 100 1

Limit (cost=13,162.70..60,179.71 rows=100 width=741) (actual time=767.726..1,064.047 rows=100 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, (floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 1) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 2) ELSE NULL::numeric END)::text)::numeric)), (floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 3) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 4) ELSE NULL::numeric END)::text)::numeric)), (CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 5) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 6) ELSE NULL::timestamp with time zone END), ((((floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 7) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 8) ELSE NULL::numeric END)::text)::numeric))::text)::numeric - ((floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 9) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 10) ELSE NULL::numeric END)::text)::numeric))::text)::numeric)), device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.radio_id, device.first_seen, address.id, address.street_address_1, address.street_address_2, address.country_id, address.state_id, address.city, address.post_code, address.gps_lat, address.gps_lng, address.created, address.updated, address.deleted, address.update_user_id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Buffers: shared hit=201959, temp read=374 written=372
2. 2.699 1,063.925 ↑ 28.2 100 1

Result (cost=13,162.70..1,339,042.40 rows=2,820 width=741) (actual time=767.721..1,063.925 rows=100 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 1) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 2) ELSE NULL::numeric END)::text)::numeric), floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 3) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 4) ELSE NULL::numeric END)::text)::numeric), CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 5) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 6) ELSE NULL::timestamp with time zone END, (((floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 7) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 8) ELSE NULL::numeric END)::text)::numeric))::text)::numeric - ((floor(((CASE WHEN (customer_device_history.unassigned IS NULL) THEN (SubPlan 9) WHEN (customer_device_history.unassigned IS NOT NULL) THEN (SubPlan 10) ELSE NULL::numeric END)::text)::numeric))::text)::numeric), device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.radio_id, device.first_seen, address.id, address.street_address_1, address.street_address_2, address.country_id, address.state_id, address.city, address.post_code, address.gps_lat, address.gps_lng, address.created, address.updated, address.deleted, address.update_user_id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Buffers: shared hit=201959, temp read=374 written=372
3. 60.833 751.026 ↑ 28.2 100 1

Sort (cost=13,162.70..13,169.75 rows=2,820 width=637) (actual time=750.934..751.026 rows=100 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.radio_id, device.first_seen, address.id, address.street_address_1, address.street_address_2, address.country_id, address.state_id, address.city, address.post_code, address.gps_lat, address.gps_lng, address.created, address.updated, address.deleted, address.update_user_id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Sort Key: customer.reference
  • Sort Method: top-N heapsort Memory: 76kB
  • Buffers: shared hit=179057, temp read=374 written=372
4. 56.159 690.193 ↓ 8.9 25,059 1

Nested Loop (cost=6,645.04..13,054.92 rows=2,820 width=637) (actual time=277.629..690.193 rows=25,059 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.radio_id, device.first_seen, address.id, address.street_address_1, address.street_address_2, address.country_id, address.state_id, address.city, address.post_code, address.gps_lat, address.gps_lng, address.created, address.updated, address.deleted, address.update_user_id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Buffers: shared hit=179054, temp read=374 written=372
5. 55.641 533.798 ↓ 8.9 25,059 1

Nested Loop (cost=6,644.63..10,748.51 rows=2,820 width=420) (actual time=277.612..533.798 rows=25,059 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id, device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.radio_id, device.first_seen
  • Buffers: shared hit=78594, temp read=374 written=372
6. 54.976 377.921 ↓ 8.3 25,059 1

Hash Join (cost=6,644.34..7,645.06 rows=3,002 width=297) (actual time=277.587..377.921 rows=25,059 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id, customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Hash Cond: (customer_device_history.customer_id = customer.id)
  • Buffers: shared hit=3281, temp read=374 written=372
7. 25.045 274.793 ↓ 8.3 25,074 1

Subquery Scan on customer_device_history (cost=3,879.49..3,939.87 rows=3,019 width=56) (actual time=229.298..274.793 rows=25,074 loops=1)

  • Output: customer_device_history.device_id, customer_device_history.customer_id, customer_device_history.assigned, customer_device_history.unassigned, customer_device_history.id
  • Buffers: shared hit=1988
8. 44.491 249.748 ↓ 8.3 25,074 1

HashAggregate (cost=3,879.49..3,909.68 rows=3,019 width=56) (actual time=229.296..249.748 rows=25,074 loops=1)

  • Output: ((((((COALESCE(cd.id, 0))::text || '-'::text) || (COALESCE(cd.customer_id, 0))::text) || '-'::text) || (COALESCE(cd.device_id, 0))::text)), cd.customer_id, cd.device_id, (lower(cd.duration)), (upper(cd.duration))
  • Group Key: ((((((COALESCE(cd.id, 0))::text || '-'::text) || (COALESCE(cd.customer_id, 0))::text) || '-'::text) || (COALESCE(cd.device_id, 0))::text)), cd.customer_id, cd.device_id, (lower(cd.duration)), (upper(cd.duration))
  • Buffers: shared hit=1988
9. 23.796 205.257 ↓ 8.3 25,074 1

Append (cost=1,954.04..3,841.75 rows=3,019 width=56) (actual time=108.868..205.257 rows=25,074 loops=1)

  • Buffers: shared hit=1988
10. 55.211 181.413 ↓ 8.3 25,074 1

Hash Join (cost=1,954.04..3,811.48 rows=3,017 width=56) (actual time=108.866..181.413 rows=25,074 loops=1)

  • Output: (((((COALESCE(cd.id, 0))::text || '-'::text) || (COALESCE(cd.customer_id, 0))::text) || '-'::text) || (COALESCE(cd.device_id, 0))::text), cd.customer_id, cd.device_id, lower(cd.duration), upper(cd.duration)
  • Hash Cond: (c.id = cd.customer_id)
  • Buffers: shared hit=1985
11. 17.393 17.393 ↑ 1.0 25,317 1

Seq Scan on public.customer c (cost=0.00..1,546.87 rows=25,317 width=4) (actual time=0.004..17.393 rows=25,317 loops=1)

  • Output: c.id, c.entity_id, c.name, c.street_address_1, c.street_address_2, c.country_id, c.state_id, c.city, c.post_code, c.created, c.updated, c.deleted, c.update_user_id, c.reference, c.extras, c.phone, c.phone_mobile, c.email, c.prism, c.phonetic_name, c.contact_1, c.contact_2, c.contact_3, c.comment
  • Filter: (c.deleted IS NULL)
  • Rows Removed by Filter: 70
  • Buffers: shared hit=1293
12. 17.059 108.809 ↓ 8.3 25,074 1

Hash (cost=1,916.22..1,916.22 rows=3,026 width=26) (actual time=108.809..108.809 rows=25,074 loops=1)

  • Output: cd.id, cd.customer_id, cd.device_id, cd.duration
  • Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1677kB
  • Buffers: shared hit=692
13. 32.278 91.750 ↓ 8.3 25,074 1

Hash Join (cost=983.89..1,916.22 rows=3,026 width=26) (actual time=42.178..91.750 rows=25,074 loops=1)

  • Output: cd.id, cd.customer_id, cd.device_id, cd.duration
  • Hash Cond: (d.id = cd.device_id)
  • Buffers: shared hit=692
14. 17.331 17.331 ↑ 1.0 27,032 1

Seq Scan on public.device d (cost=0.00..699.33 rows=27,032 width=4) (actual time=0.006..17.331 rows=27,032 loops=1)

  • Output: d.id, d.active, d.eid, d.entity_id, d.address_id, d.device_type_id, d.device_group_id, d.parent_id, d.communication_status_id, d.last_seen, d.created, d.updated, d.deleted, d.update_user_id, d.installed, d.application_profile_id, d.serial, d.first_seen, d.radio_id
  • Filter: (d.deleted IS NULL)
  • Rows Removed by Filter: 601
  • Buffers: shared hit=423
15. 16.526 42.141 ↓ 8.1 25,074 1

Hash (cost=945.23..945.23 rows=3,093 width=26) (actual time=42.141..42.141 rows=25,074 loops=1)

  • Output: cd.id, cd.customer_id, cd.device_id, cd.duration
  • Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1677kB
  • Buffers: shared hit=269
16. 25.615 25.615 ↓ 8.1 25,074 1

Seq Scan on public.customer_device cd (cost=0.00..945.23 rows=3,093 width=26) (actual time=0.060..25.615 rows=25,074 loops=1)

  • Output: cd.id, cd.customer_id, cd.device_id, cd.duration
  • Filter: ((cd.customer_id IS NOT NULL) AND (cd.device_id IS NOT NULL) AND ((lower(cd.duration) <= '2020-05-13 14:00:00+00'::timestamp with time zone) OR (lower(cd.duration) IS NULL)) AND ((upper(cd.duration) >= '2020-04-12 14:00:00+00'::timestamp with time zone) OR (upper(cd.duration) IS NULL)))
  • Rows Removed by Filter: 2215
  • Buffers: shared hit=269
17. 0.002 0.048 ↓ 0.0 0 1

Subquery Scan on customer_device_unassigned (cost=0.01..0.08 rows=2 width=56) (actual time=0.048..0.048 rows=0 loops=1)

  • Output: ((('0-'::text || (COALESCE(customer_device_unassigned.customer_id, 0))::text) || '-'::text) || (COALESCE(customer_device_unassigned.device_id, 0))::text), customer_device_unassigned.customer_id, customer_device_unassigned.device_id, NULL::timestamp with time zone, NULL::timestamp with time zone
  • Buffers: shared hit=3
18. 0.001 0.046 ↓ 0.0 0 1

Unique (cost=0.01..0.03 rows=2 width=8) (actual time=0.046..0.046 rows=0 loops=1)

  • Output: id, (NULL::integer)
  • Buffers: shared hit=3
19. 0.040 0.045 ↓ 0.0 0 1

Sort (cost=0.01..0.02 rows=2 width=8) (actual time=0.045..0.045 rows=0 loops=1)

  • Output: id, (NULL::integer)
  • Sort Key: id, (NULL::integer)
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=3
20. 0.003 0.005 ↓ 0.0 0 1

Append (cost=0.00..0.00 rows=2 width=8) (actual time=0.005..0.005 rows=0 loops=1)

21. 0.001 0.001 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=8) (actual time=0.001..0.001 rows=0 loops=1)

  • Output: id, NULL::integer
  • One-Time Filter: false
22. 0.001 0.001 ↓ 0.0 0 1

Result (cost=0.00..0.00 rows=0 width=8) (actual time=0.001..0.001 rows=0 loops=1)

  • Output: NULL::integer, id
  • One-Time Filter: false
23. 24.898 48.152 ↑ 1.0 25,241 1

Hash (cost=1,610.34..1,610.34 rows=25,241 width=241) (actual time=48.152..48.152 rows=25,241 loops=1)

  • Output: customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Buckets: 16384 Batches: 2 Memory Usage: 2605kB
  • Buffers: shared hit=1293, temp written=289
24. 23.254 23.254 ↑ 1.0 25,241 1

Seq Scan on public.customer (cost=0.00..1,610.34 rows=25,241 width=241) (actual time=0.008..23.254 rows=25,241 loops=1)

  • Output: customer.id, customer.entity_id, customer.reference, customer.name, customer.phonetic_name, customer.contact_1, customer.contact_2, customer.contact_3, customer.comment, customer.street_address_1, customer.street_address_2, customer.country_id, customer.state_id, customer.city, customer.post_code, customer.phone, customer.phone_mobile, customer.email, customer.prism, customer.extras, customer.created, customer.updated, customer.deleted, customer.update_user_id
  • Filter: ((customer.deleted IS NULL) AND (customer.entity_id = 1))
  • Rows Removed by Filter: 146
  • Buffers: shared hit=1293
25. 100.236 100.236 ↑ 1.0 1 25,059

Index Scan using device_pkey on public.device (cost=0.29..1.02 rows=1 width=123) (actual time=0.003..0.004 rows=1 loops=25,059)

  • Output: device.id, device.active, device.eid, device.entity_id, device.address_id, device.device_type_id, device.device_group_id, device.parent_id, device.communication_status_id, device.last_seen, device.created, device.updated, device.deleted, device.update_user_id, device.installed, device.application_profile_id, device.serial, device.first_seen, device.radio_id
  • Index Cond: (device.id = customer_device_history.device_id)
  • Filter: ((device.deleted IS NULL) AND (device.entity_id = 1) AND (device.device_type_id = ANY ('{2549,2,527,538,599,742,541,528,543,621,622,623,708,539,637,638,816,1107,1108,1242,1243,1267,1447,1448,1449,540,1453,872,873,874,875,876,877,878,879,880,881,882,883,884,2578,3829}'::integer[])))
  • Buffers: shared hit=75313
26. 100.236 100.236 ↑ 1.0 1 25,059

Index Scan using address_pkey on public.address (cost=0.41..0.81 rows=1 width=217) (actual time=0.003..0.004 rows=1 loops=25,059)

  • Output: address.id, address.street_address_1, address.street_address_2, address.country_id, address.state_id, address.city, address.post_code, address.gps_lat, address.gps_lng, address.created, address.updated, address.deleted, address.update_user_id, address.geom
  • Index Cond: (address.id = device.address_id)
  • Buffers: shared hit=100460
27.          

SubPlan (for Result)

28. 0.200 66.300 ↑ 1.0 1 100

Limit (cost=47.62..47.90 rows=1 width=40) (actual time=0.663..0.663 rows=1 loops=100)

  • Output: (CASE WHEN (drh.calculated IS NOT NULL) THEN drh.calculated_value ELSE (CASE WHEN ((rm.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh.device_id, rm.attributes, drh.value, drh.updated) ELSE ((drh.value)::text)::numeric END * COALESCE(((rm.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh.updated
  • Buffers: shared hit=4838
29. 0.200 66.100 ↑ 1.0 1 100

Result (cost=47.62..47.90 rows=1 width=40) (actual time=0.661..0.661 rows=1 loops=100)

  • Output: CASE WHEN (drh.calculated IS NOT NULL) THEN drh.calculated_value ELSE (CASE WHEN ((rm.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh.device_id, rm.attributes, drh.value, drh.updated) ELSE ((drh.value)::text)::numeric END * COALESCE(((rm.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh.updated
  • Buffers: shared hit=4838
30. 1.000 65.900 ↑ 1.0 1 100

Sort (cost=47.62..47.62 rows=1 width=209) (actual time=0.659..0.659 rows=1 loops=100)

  • Output: drh.updated, drh.calculated, drh.calculated_value, rm.attributes, drh.device_id, drh.value
  • Sort Key: drh.updated
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=4838
31. 11.798 64.900 ↓ 4.0 4 100

Nested Loop (cost=7.29..47.61 rows=1 width=209) (actual time=0.156..0.649 rows=4 loops=100)

  • Output: drh.updated, drh.calculated, drh.calculated_value, rm.attributes, drh.device_id, drh.value
  • Join Filter: (d_1.device_type_id = dt.id)
  • Rows Removed by Join Filter: 192
  • Buffers: shared hit=4835
32. 0.969 43.300 ↓ 4.0 4 100

Nested Loop (cost=7.29..44.44 rows=1 width=213) (actual time=0.143..0.433 rows=4 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, rm.attributes, d_1.device_type_id
  • Buffers: shared hit=4081
33. 6.791 41.200 ↓ 4.0 4 100

Nested Loop (cost=7.00..36.12 rows=1 width=209) (actual time=0.138..0.412 rows=4 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, rm.attributes
  • Join Filter: (rg.resource_group_meta_id = rgm.id)
  • Rows Removed by Join Filter: 113
  • Buffers: shared hit=2950
34. 7.045 28.000 ↓ 4.0 4 100

Nested Loop (cost=7.00..34.42 rows=1 width=213) (actual time=0.126..0.280 rows=4 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, rm.attributes, rg.resource_group_meta_id
  • Join Filter: (r.resource_group_id = rg.id)
  • Rows Removed by Join Filter: 106
  • Buffers: shared hit=2573
35. 0.969 15.300 ↓ 4.0 4 100

Nested Loop (cost=7.00..32.77 rows=1 width=213) (actual time=0.121..0.153 rows=4 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, r.resource_group_id, rm.attributes
  • Buffers: shared hit=2196
36. 0.742 13.200 ↓ 4.0 4 100

Hash Join (cost=6.86..27.52 rows=1 width=59) (actual time=0.117..0.132 rows=4 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, r.resource_meta_id, r.resource_group_id
  • Hash Cond: (drh.resource_id = r.id)
  • Buffers: shared hit=1442
37. 1.200 12.200 ↑ 1.2 4 100

Append (cost=0.00..20.64 rows=5 width=55) (actual time=0.112..0.122 rows=4 loops=100)

  • Buffers: shared hit=1438
38. 0.100 0.100 ↓ 0.0 0 100

Seq Scan on public.device_resource_history drh (cost=0.00..0.00 rows=1 width=88) (actual time=0.001..0.001 rows=0 loops=100)

  • Output: drh.calculated, drh.calculated_value, drh.device_id, drh.value, drh.updated, drh.resource_id
  • Filter: ((drh.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh.updated >= customer_device_history.assigned) AND (drh.device_id = customer_device_history.device_id))
39. 0.400 0.400 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_1 (cost=0.00..1.16 rows=1 width=46) (actual time=0.004..0.004 rows=0 loops=100)

  • Output: drh_1.calculated, drh_1.calculated_value, drh_1.device_id, drh_1.value, drh_1.updated, drh_1.resource_id
  • Filter: ((drh_1.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_1.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_1.updated >= customer_device_history.assigned) AND (drh_1.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 8
  • Buffers: shared hit=100
40. 1.600 1.600 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_2 (cost=0.00..3.06 rows=1 width=46) (actual time=0.016..0.016 rows=0 loops=100)

  • Output: drh_2.calculated, drh_2.calculated_value, drh_2.device_id, drh_2.value, drh_2.updated, drh_2.resource_id
  • Filter: ((drh_2.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_2.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_2.updated >= customer_device_history.assigned) AND (drh_2.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 53
  • Buffers: shared hit=200
41. 4.800 7.700 ↓ 0.0 0 100

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_3 (cost=4.17..7.97 rows=1 width=49) (actual time=0.077..0.077 rows=0 loops=100)

  • Output: drh_3.calculated, drh_3.calculated_value, drh_3.device_id, drh_3.value, drh_3.updated, drh_3.resource_id
  • Recheck Cond: ((drh_3.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_3.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_3.updated >= customer_device_history.assigned))
  • Filter: (drh_3.device_id = customer_device_history.device_id)
  • Rows Removed by Filter: 364
  • Heap Blocks: exact=400
  • Buffers: shared hit=500
42. 2.900 2.900 ↓ 182.0 364 100

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.17 rows=2 width=0) (actual time=0.029..0.029 rows=364 loops=100)

  • Index Cond: ((drh_3.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_3.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_3.updated >= customer_device_history.assigned))
  • Buffers: shared hit=100
43. 1.200 1.200 ↓ 4.0 4 100

Index Scan using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_4 (cost=0.42..8.45 rows=1 width=48) (actual time=0.005..0.012 rows=4 loops=100)

  • Output: drh_4.calculated, drh_4.calculated_value, drh_4.device_id, drh_4.value, drh_4.updated, drh_4.resource_id
  • Index Cond: ((drh_4.device_id = customer_device_history.device_id) AND (drh_4.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_4.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_4.updated >= customer_device_history.assigned))
  • Buffers: shared hit=638
44. 0.015 0.258 ↑ 1.0 18 1

Hash (cost=6.63..6.63 rows=18 width=16) (actual time=0.258..0.258 rows=18 loops=1)

  • Output: r.id, r.resource_meta_id, r.resource_group_id, u0.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=4
45. 0.068 0.243 ↑ 1.0 18 1

Hash Join (cost=3.06..6.63 rows=18 width=16) (actual time=0.121..0.243 rows=18 loops=1)

  • Output: r.id, r.resource_meta_id, r.resource_group_id, u0.primary_resource_id
  • Hash Cond: (r.id = u0.primary_resource_id)
  • Buffers: shared hit=4
46. 0.071 0.071 ↑ 1.0 104 1

Seq Scan on public.resource r (cost=0.00..3.04 rows=104 width=12) (actual time=0.005..0.071 rows=104 loops=1)

  • Output: r.id, r.resource_meta_id, r.resource_group_id, r.measurement, r.field_name, r.created, r.updated, r.deleted
  • Buffers: shared hit=2
47. 0.016 0.104 ↑ 1.0 18 1

Hash (cost=2.83..2.83 rows=18 width=4) (actual time=0.104..0.104 rows=18 loops=1)

  • Output: u0.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2
48. 0.050 0.088 ↓ 1.1 19 1

HashAggregate (cost=2.65..2.83 rows=18 width=4) (actual time=0.077..0.088 rows=19 loops=1)

  • Output: u0.primary_resource_id
  • Group Key: u0.primary_resource_id
  • Buffers: shared hit=2
49. 0.038 0.038 ↑ 1.0 52 1

Seq Scan on public.device_type u0 (cost=0.00..2.52 rows=52 width=4) (actual time=0.005..0.038 rows=52 loops=1)

  • Output: u0.primary_resource_id
  • Buffers: shared hit=2
50. 1.131 1.131 ↑ 1.0 1 377

Index Scan using resource_meta_pkey on public.resource_meta rm (cost=0.14..5.24 rows=1 width=162) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: rm.id, rm.resource_group_meta_id, rm.code, rm.description, rm.value_type, rm.unit_of_measure, rm.attributes, rm.created, rm.updated, rm.deleted
  • Index Cond: (rm.id = r.resource_meta_id)
  • Buffers: shared hit=754
51. 5.655 5.655 ↑ 1.0 29 377

Seq Scan on public.resource_group rg (cost=0.00..1.29 rows=29 width=8) (actual time=0.001..0.015 rows=29 loops=377)

  • Output: rg.id, rg.resource_group_meta_id, rg.code, rg.description, rg.created, rg.updated, rg.deleted
  • Buffers: shared hit=377
52. 6.409 6.409 ↑ 1.0 31 377

Seq Scan on public.resource_group_meta rgm (cost=0.00..1.31 rows=31 width=4) (actual time=0.001..0.017 rows=31 loops=377)

  • Output: rgm.id, rgm.code, rgm.description, rgm.created, rgm.updated, rgm.deleted
  • Buffers: shared hit=377
53. 1.131 1.131 ↑ 1.0 1 377

Index Scan using device_pkey on public.device d_1 (cost=0.29..8.30 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: d_1.id, d_1.active, d_1.eid, d_1.entity_id, d_1.address_id, d_1.device_type_id, d_1.device_group_id, d_1.parent_id, d_1.communication_status_id, d_1.last_seen, d_1.created, d_1.updated, d_1.deleted, d_1.update_user_id, d_1.installed, d_1.application_profile_id, d_1.serial, d_1.first_seen, d_1.radio_id
  • Index Cond: (d_1.id = customer_device_history.device_id)
  • Buffers: shared hit=1131
54. 9.802 9.802 ↑ 1.0 52 377

Seq Scan on public.device_type dt (cost=0.00..2.52 rows=52 width=4) (actual time=0.001..0.026 rows=52 loops=377)

  • Output: dt.id, dt.name, dt.description, dt.created, dt.updated, dt.deleted, dt.update_user_id, dt.code, dt.primary_resource_id, dt.device_category_id, dt.active, dt.market, dt.default_application_profile_id, dt.status_policy, dt.has_meterage
  • Buffers: shared hit=754
55. 0.000 0.000 ↓ 0.0 0

Limit (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: (CASE WHEN (drh_5.calculated IS NOT NULL) THEN drh_5.calculated_value ELSE (CASE WHEN ((rm_1.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_5.device_id, rm_1.attributes, drh_5.value, drh_5.updated) ELSE ((drh_5.value)::text)::numeric END * COALESCE(((rm_1.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_5.updated
56. 0.000 0.000 ↓ 0.0 0

Result (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: CASE WHEN (drh_5.calculated IS NOT NULL) THEN drh_5.calculated_value ELSE (CASE WHEN ((rm_1.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_5.device_id, rm_1.attributes, drh_5.value, drh_5.updated) ELSE ((drh_5.value)::text)::numeric END * COALESCE(((rm_1.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_5.updated
57. 0.000 0.000 ↓ 0.0 0

Sort (cost=47.78..47.79 rows=1 width=209) (never executed)

  • Output: drh_5.updated, drh_5.calculated, drh_5.calculated_value, rm_1.attributes, drh_5.device_id, drh_5.value
  • Sort Key: drh_5.updated
58. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..47.77 rows=1 width=209) (never executed)

  • Output: drh_5.updated, drh_5.calculated, drh_5.calculated_value, rm_1.attributes, drh_5.device_id, drh_5.value
  • Join Filter: (d_2.device_type_id = dt_1.id)
59. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..44.60 rows=1 width=213) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, rm_1.attributes, d_2.device_type_id
60. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..36.29 rows=1 width=209) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, rm_1.attributes
  • Join Filter: (rg_1.resource_group_meta_id = rgm_1.id)
61. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..34.59 rows=1 width=213) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, rm_1.attributes, rg_1.resource_group_meta_id
  • Join Filter: (r_1.resource_group_id = rg_1.id)
62. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..32.94 rows=1 width=213) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, r_1.resource_group_id, rm_1.attributes
63. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=6.86..27.69 rows=1 width=59) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, r_1.resource_meta_id, r_1.resource_group_id
  • Hash Cond: (drh_5.resource_id = r_1.id)
64. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..20.80 rows=5 width=55) (never executed)

65. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_resource_history drh_5 (cost=0.00..0.00 rows=1 width=88) (never executed)

  • Output: drh_5.calculated, drh_5.calculated_value, drh_5.device_id, drh_5.value, drh_5.updated, drh_5.resource_id
  • Filter: ((drh_5.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_5.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_5.updated >= customer_device_history.assigned) AND (drh_5.updated <= customer_device_history.unassigned) AND (drh_5.device_id = customer_device_history.device_id))
66. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_6 (cost=0.00..1.18 rows=1 width=46) (never executed)

  • Output: drh_6.calculated, drh_6.calculated_value, drh_6.device_id, drh_6.value, drh_6.updated, drh_6.resource_id
  • Filter: ((drh_6.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_6.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_6.updated >= customer_device_history.assigned) AND (drh_6.updated <= customer_device_history.unassigned) AND (drh_6.device_id = customer_device_history.device_id))
67. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_7 (cost=0.00..3.19 rows=1 width=46) (never executed)

  • Output: drh_7.calculated, drh_7.calculated_value, drh_7.device_id, drh_7.value, drh_7.updated, drh_7.resource_id
  • Filter: ((drh_7.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_7.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_7.updated >= customer_device_history.assigned) AND (drh_7.updated <= customer_device_history.unassigned) AND (drh_7.device_id = customer_device_history.device_id))
68. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_8 (cost=4.18..7.98 rows=1 width=49) (never executed)

  • Output: drh_8.calculated, drh_8.calculated_value, drh_8.device_id, drh_8.value, drh_8.updated, drh_8.resource_id
  • Recheck Cond: ((drh_8.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_8.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_8.updated >= customer_device_history.assigned) AND (drh_8.updated <= customer_device_history.unassigned))
  • Filter: (drh_8.device_id = customer_device_history.device_id)
69. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.18 rows=2 width=0) (never executed)

  • Index Cond: ((drh_8.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_8.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_8.updated >= customer_device_history.assigned) AND (drh_8.updated <= customer_device_history.unassigned))
70. 0.000 0.000 ↓ 0.0 0

Index Scan using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_9 (cost=0.42..8.45 rows=1 width=48) (never executed)

  • Output: drh_9.calculated, drh_9.calculated_value, drh_9.device_id, drh_9.value, drh_9.updated, drh_9.resource_id
  • Index Cond: ((drh_9.device_id = customer_device_history.device_id) AND (drh_9.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_9.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_9.updated >= customer_device_history.assigned) AND (drh_9.updated <= customer_device_history.unassigned))
71. 0.000 0.000 ↓ 0.0 0

Hash (cost=6.63..6.63 rows=18 width=16) (never executed)

  • Output: r_1.id, r_1.resource_meta_id, r_1.resource_group_id, u0_1.primary_resource_id
72. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=3.06..6.63 rows=18 width=16) (never executed)

  • Output: r_1.id, r_1.resource_meta_id, r_1.resource_group_id, u0_1.primary_resource_id
  • Hash Cond: (r_1.id = u0_1.primary_resource_id)
73. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource r_1 (cost=0.00..3.04 rows=104 width=12) (never executed)

  • Output: r_1.id, r_1.resource_meta_id, r_1.resource_group_id, r_1.measurement, r_1.field_name, r_1.created, r_1.updated, r_1.deleted
74. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.83..2.83 rows=18 width=4) (never executed)

  • Output: u0_1.primary_resource_id
75. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=2.65..2.83 rows=18 width=4) (never executed)

  • Output: u0_1.primary_resource_id
  • Group Key: u0_1.primary_resource_id
76. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type u0_1 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: u0_1.primary_resource_id
77. 0.000 0.000 ↓ 0.0 0

Index Scan using resource_meta_pkey on public.resource_meta rm_1 (cost=0.14..5.24 rows=1 width=162) (never executed)

  • Output: rm_1.id, rm_1.resource_group_meta_id, rm_1.code, rm_1.description, rm_1.value_type, rm_1.unit_of_measure, rm_1.attributes, rm_1.created, rm_1.updated, rm_1.deleted
  • Index Cond: (rm_1.id = r_1.resource_meta_id)
78. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group rg_1 (cost=0.00..1.29 rows=29 width=8) (never executed)

  • Output: rg_1.id, rg_1.resource_group_meta_id, rg_1.code, rg_1.description, rg_1.created, rg_1.updated, rg_1.deleted
79. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group_meta rgm_1 (cost=0.00..1.31 rows=31 width=4) (never executed)

  • Output: rgm_1.id, rgm_1.code, rgm_1.description, rgm_1.created, rgm_1.updated, rgm_1.deleted
80. 0.000 0.000 ↓ 0.0 0

Index Scan using device_pkey on public.device d_2 (cost=0.29..8.30 rows=1 width=8) (never executed)

  • Output: d_2.id, d_2.active, d_2.eid, d_2.entity_id, d_2.address_id, d_2.device_type_id, d_2.device_group_id, d_2.parent_id, d_2.communication_status_id, d_2.last_seen, d_2.created, d_2.updated, d_2.deleted, d_2.update_user_id, d_2.installed, d_2.application_profile_id, d_2.serial, d_2.first_seen, d_2.radio_id
  • Index Cond: (d_2.id = customer_device_history.device_id)
81. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type dt_1 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: dt_1.id, dt_1.name, dt_1.description, dt_1.created, dt_1.updated, dt_1.deleted, dt_1.update_user_id, dt_1.code, dt_1.primary_resource_id, dt_1.device_category_id, dt_1.active, dt_1.market, dt_1.default_application_profile_id, dt_1.status_policy, dt_1.has_meterage
82. 0.200 65.900 ↑ 1.0 1 100

Limit (cost=47.62..47.90 rows=1 width=40) (actual time=0.658..0.659 rows=1 loops=100)

  • Output: (CASE WHEN (drh_10.calculated IS NOT NULL) THEN drh_10.calculated_value ELSE (CASE WHEN ((rm_2.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_10.device_id, rm_2.attributes, drh_10.value, drh_10.updated) ELSE ((drh_10.value)::text)::numeric END * COALESCE(((rm_2.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_10.updated
  • Buffers: shared hit=4933
83. 0.200 65.700 ↑ 1.0 1 100

Result (cost=47.62..47.90 rows=1 width=40) (actual time=0.657..0.657 rows=1 loops=100)

  • Output: CASE WHEN (drh_10.calculated IS NOT NULL) THEN drh_10.calculated_value ELSE (CASE WHEN ((rm_2.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_10.device_id, rm_2.attributes, drh_10.value, drh_10.updated) ELSE ((drh_10.value)::text)::numeric END * COALESCE(((rm_2.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_10.updated
  • Buffers: shared hit=4933
84. 1.000 65.500 ↑ 1.0 1 100

Sort (cost=47.62..47.62 rows=1 width=209) (actual time=0.655..0.655 rows=1 loops=100)

  • Output: drh_10.updated, drh_10.calculated, drh_10.calculated_value, rm_2.attributes, drh_10.device_id, drh_10.value
  • Sort Key: drh_10.updated DESC
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=4933
85. 11.698 64.500 ↓ 4.0 4 100

Nested Loop (cost=7.29..47.61 rows=1 width=209) (actual time=0.155..0.645 rows=4 loops=100)

  • Output: drh_10.updated, drh_10.calculated, drh_10.calculated_value, rm_2.attributes, drh_10.device_id, drh_10.value
  • Join Filter: (d_3.device_type_id = dt_2.id)
  • Rows Removed by Join Filter: 192
  • Buffers: shared hit=4933
86. 0.969 43.000 ↓ 4.0 4 100

Nested Loop (cost=7.29..44.44 rows=1 width=213) (actual time=0.142..0.430 rows=4 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, rm_2.attributes, d_3.device_type_id
  • Buffers: shared hit=4179
87. 7.168 40.900 ↓ 4.0 4 100

Nested Loop (cost=7.00..36.12 rows=1 width=209) (actual time=0.137..0.409 rows=4 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, rm_2.attributes
  • Join Filter: (rg_2.resource_group_meta_id = rgm_2.id)
  • Rows Removed by Join Filter: 113
  • Buffers: shared hit=3048
88. 7.045 27.700 ↓ 4.0 4 100

Nested Loop (cost=7.00..34.42 rows=1 width=213) (actual time=0.125..0.277 rows=4 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, rm_2.attributes, rg_2.resource_group_meta_id
  • Join Filter: (r_2.resource_group_id = rg_2.id)
  • Rows Removed by Join Filter: 106
  • Buffers: shared hit=2671
89. 0.869 15.000 ↓ 4.0 4 100

Nested Loop (cost=7.00..32.77 rows=1 width=213) (actual time=0.120..0.150 rows=4 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, r_2.resource_group_id, rm_2.attributes
  • Buffers: shared hit=2294
90. 0.850 13.000 ↓ 4.0 4 100

Hash Join (cost=6.86..27.52 rows=1 width=59) (actual time=0.116..0.130 rows=4 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, r_2.resource_meta_id, r_2.resource_group_id
  • Hash Cond: (drh_10.resource_id = r_2.id)
  • Buffers: shared hit=1540
91. 1.100 11.900 ↑ 1.2 4 100

Append (cost=0.00..20.64 rows=5 width=55) (actual time=0.110..0.119 rows=4 loops=100)

  • Buffers: shared hit=1536
92. 0.100 0.100 ↓ 0.0 0 100

Seq Scan on public.device_resource_history drh_10 (cost=0.00..0.00 rows=1 width=88) (actual time=0.001..0.001 rows=0 loops=100)

  • Output: drh_10.calculated, drh_10.calculated_value, drh_10.device_id, drh_10.value, drh_10.updated, drh_10.resource_id
  • Filter: ((drh_10.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_10.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_10.updated >= customer_device_history.assigned) AND (drh_10.device_id = customer_device_history.device_id))
93. 0.500 0.500 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_11 (cost=0.00..1.16 rows=1 width=46) (actual time=0.005..0.005 rows=0 loops=100)

  • Output: drh_11.calculated, drh_11.calculated_value, drh_11.device_id, drh_11.value, drh_11.updated, drh_11.resource_id
  • Filter: ((drh_11.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_11.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_11.updated >= customer_device_history.assigned) AND (drh_11.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 8
  • Buffers: shared hit=100
94. 1.600 1.600 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_12 (cost=0.00..3.06 rows=1 width=46) (actual time=0.016..0.016 rows=0 loops=100)

  • Output: drh_12.calculated, drh_12.calculated_value, drh_12.device_id, drh_12.value, drh_12.updated, drh_12.resource_id
  • Filter: ((drh_12.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_12.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_12.updated >= customer_device_history.assigned) AND (drh_12.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 53
  • Buffers: shared hit=200
95. 4.800 7.700 ↓ 0.0 0 100

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_13 (cost=4.17..7.97 rows=1 width=49) (actual time=0.077..0.077 rows=0 loops=100)

  • Output: drh_13.calculated, drh_13.calculated_value, drh_13.device_id, drh_13.value, drh_13.updated, drh_13.resource_id
  • Recheck Cond: ((drh_13.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_13.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_13.updated >= customer_device_history.assigned))
  • Filter: (drh_13.device_id = customer_device_history.device_id)
  • Rows Removed by Filter: 364
  • Heap Blocks: exact=400
  • Buffers: shared hit=500
96. 2.900 2.900 ↓ 182.0 364 100

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.17 rows=2 width=0) (actual time=0.029..0.029 rows=364 loops=100)

  • Index Cond: ((drh_13.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_13.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_13.updated >= customer_device_history.assigned))
  • Buffers: shared hit=100
97. 0.900 0.900 ↓ 4.0 4 100

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_14 (cost=0.42..8.45 rows=1 width=48) (actual time=0.004..0.009 rows=4 loops=100)

  • Output: drh_14.calculated, drh_14.calculated_value, drh_14.device_id, drh_14.value, drh_14.updated, drh_14.resource_id
  • Index Cond: ((drh_14.device_id = customer_device_history.device_id) AND (drh_14.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_14.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_14.updated >= customer_device_history.assigned))
  • Buffers: shared hit=736
98. 0.018 0.250 ↑ 1.0 18 1

Hash (cost=6.63..6.63 rows=18 width=16) (actual time=0.250..0.250 rows=18 loops=1)

  • Output: r_2.id, r_2.resource_meta_id, r_2.resource_group_id, u0_2.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=4
99. 0.105 0.232 ↑ 1.0 18 1

Hash Join (cost=3.06..6.63 rows=18 width=16) (actual time=0.113..0.232 rows=18 loops=1)

  • Output: r_2.id, r_2.resource_meta_id, r_2.resource_group_id, u0_2.primary_resource_id
  • Hash Cond: (r_2.id = u0_2.primary_resource_id)
  • Buffers: shared hit=4
100. 0.028 0.028 ↑ 1.0 104 1

Seq Scan on public.resource r_2 (cost=0.00..3.04 rows=104 width=12) (actual time=0.004..0.028 rows=104 loops=1)

  • Output: r_2.id, r_2.resource_meta_id, r_2.resource_group_id, r_2.measurement, r_2.field_name, r_2.created, r_2.updated, r_2.deleted
  • Buffers: shared hit=2
101. 0.014 0.099 ↑ 1.0 18 1

Hash (cost=2.83..2.83 rows=18 width=4) (actual time=0.099..0.099 rows=18 loops=1)

  • Output: u0_2.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2
102. 0.045 0.085 ↓ 1.1 19 1

HashAggregate (cost=2.65..2.83 rows=18 width=4) (actual time=0.073..0.085 rows=19 loops=1)

  • Output: u0_2.primary_resource_id
  • Group Key: u0_2.primary_resource_id
  • Buffers: shared hit=2
103. 0.040 0.040 ↑ 1.0 52 1

Seq Scan on public.device_type u0_2 (cost=0.00..2.52 rows=52 width=4) (actual time=0.004..0.040 rows=52 loops=1)

  • Output: u0_2.primary_resource_id
  • Buffers: shared hit=2
104. 1.131 1.131 ↑ 1.0 1 377

Index Scan using resource_meta_pkey on public.resource_meta rm_2 (cost=0.14..5.24 rows=1 width=162) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: rm_2.id, rm_2.resource_group_meta_id, rm_2.code, rm_2.description, rm_2.value_type, rm_2.unit_of_measure, rm_2.attributes, rm_2.created, rm_2.updated, rm_2.deleted
  • Index Cond: (rm_2.id = r_2.resource_meta_id)
  • Buffers: shared hit=754
105. 5.655 5.655 ↑ 1.0 29 377

Seq Scan on public.resource_group rg_2 (cost=0.00..1.29 rows=29 width=8) (actual time=0.001..0.015 rows=29 loops=377)

  • Output: rg_2.id, rg_2.resource_group_meta_id, rg_2.code, rg_2.description, rg_2.created, rg_2.updated, rg_2.deleted
  • Buffers: shared hit=377
106. 6.032 6.032 ↑ 1.0 31 377

Seq Scan on public.resource_group_meta rgm_2 (cost=0.00..1.31 rows=31 width=4) (actual time=0.001..0.016 rows=31 loops=377)

  • Output: rgm_2.id, rgm_2.code, rgm_2.description, rgm_2.created, rgm_2.updated, rgm_2.deleted
  • Buffers: shared hit=377
107. 1.131 1.131 ↑ 1.0 1 377

Index Scan using device_pkey on public.device d_3 (cost=0.29..8.30 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: d_3.id, d_3.active, d_3.eid, d_3.entity_id, d_3.address_id, d_3.device_type_id, d_3.device_group_id, d_3.parent_id, d_3.communication_status_id, d_3.last_seen, d_3.created, d_3.updated, d_3.deleted, d_3.update_user_id, d_3.installed, d_3.application_profile_id, d_3.serial, d_3.first_seen, d_3.radio_id
  • Index Cond: (d_3.id = customer_device_history.device_id)
  • Buffers: shared hit=1131
108. 9.802 9.802 ↑ 1.0 52 377

Seq Scan on public.device_type dt_2 (cost=0.00..2.52 rows=52 width=4) (actual time=0.001..0.026 rows=52 loops=377)

  • Output: dt_2.id, dt_2.name, dt_2.description, dt_2.created, dt_2.updated, dt_2.deleted, dt_2.update_user_id, dt_2.code, dt_2.primary_resource_id, dt_2.device_category_id, dt_2.active, dt_2.market, dt_2.default_application_profile_id, dt_2.status_policy, dt_2.has_meterage
  • Buffers: shared hit=754
109. 0.000 0.000 ↓ 0.0 0

Limit (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: (CASE WHEN (drh_15.calculated IS NOT NULL) THEN drh_15.calculated_value ELSE (CASE WHEN ((rm_3.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_15.device_id, rm_3.attributes, drh_15.value, drh_15.updated) ELSE ((drh_15.value)::text)::numeric END * COALESCE(((rm_3.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_15.updated
110. 0.000 0.000 ↓ 0.0 0

Result (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: CASE WHEN (drh_15.calculated IS NOT NULL) THEN drh_15.calculated_value ELSE (CASE WHEN ((rm_3.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_15.device_id, rm_3.attributes, drh_15.value, drh_15.updated) ELSE ((drh_15.value)::text)::numeric END * COALESCE(((rm_3.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_15.updated
111. 0.000 0.000 ↓ 0.0 0

Sort (cost=47.78..47.79 rows=1 width=209) (never executed)

  • Output: drh_15.updated, drh_15.calculated, drh_15.calculated_value, rm_3.attributes, drh_15.device_id, drh_15.value
  • Sort Key: drh_15.updated DESC
112. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..47.77 rows=1 width=209) (never executed)

  • Output: drh_15.updated, drh_15.calculated, drh_15.calculated_value, rm_3.attributes, drh_15.device_id, drh_15.value
  • Join Filter: (d_4.device_type_id = dt_3.id)
113. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..44.60 rows=1 width=213) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, rm_3.attributes, d_4.device_type_id
114. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..36.29 rows=1 width=209) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, rm_3.attributes
  • Join Filter: (rg_3.resource_group_meta_id = rgm_3.id)
115. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..34.59 rows=1 width=213) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, rm_3.attributes, rg_3.resource_group_meta_id
  • Join Filter: (r_3.resource_group_id = rg_3.id)
116. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..32.94 rows=1 width=213) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, r_3.resource_group_id, rm_3.attributes
117. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=6.86..27.69 rows=1 width=59) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, r_3.resource_meta_id, r_3.resource_group_id
  • Hash Cond: (drh_15.resource_id = r_3.id)
118. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..20.80 rows=5 width=55) (never executed)

119. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_resource_history drh_15 (cost=0.00..0.00 rows=1 width=88) (never executed)

  • Output: drh_15.calculated, drh_15.calculated_value, drh_15.device_id, drh_15.value, drh_15.updated, drh_15.resource_id
  • Filter: ((drh_15.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_15.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_15.updated >= customer_device_history.assigned) AND (drh_15.updated <= customer_device_history.unassigned) AND (drh_15.device_id = customer_device_history.device_id))
120. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_16 (cost=0.00..1.18 rows=1 width=46) (never executed)

  • Output: drh_16.calculated, drh_16.calculated_value, drh_16.device_id, drh_16.value, drh_16.updated, drh_16.resource_id
  • Filter: ((drh_16.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_16.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_16.updated >= customer_device_history.assigned) AND (drh_16.updated <= customer_device_history.unassigned) AND (drh_16.device_id = customer_device_history.device_id))
121. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_17 (cost=0.00..3.19 rows=1 width=46) (never executed)

  • Output: drh_17.calculated, drh_17.calculated_value, drh_17.device_id, drh_17.value, drh_17.updated, drh_17.resource_id
  • Filter: ((drh_17.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_17.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_17.updated >= customer_device_history.assigned) AND (drh_17.updated <= customer_device_history.unassigned) AND (drh_17.device_id = customer_device_history.device_id))
122. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_18 (cost=4.18..7.98 rows=1 width=49) (never executed)

  • Output: drh_18.calculated, drh_18.calculated_value, drh_18.device_id, drh_18.value, drh_18.updated, drh_18.resource_id
  • Recheck Cond: ((drh_18.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_18.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_18.updated >= customer_device_history.assigned) AND (drh_18.updated <= customer_device_history.unassigned))
  • Filter: (drh_18.device_id = customer_device_history.device_id)
123. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.18 rows=2 width=0) (never executed)

  • Index Cond: ((drh_18.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_18.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_18.updated >= customer_device_history.assigned) AND (drh_18.updated <= customer_device_history.unassigned))
124. 0.000 0.000 ↓ 0.0 0

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_19 (cost=0.42..8.45 rows=1 width=48) (never executed)

  • Output: drh_19.calculated, drh_19.calculated_value, drh_19.device_id, drh_19.value, drh_19.updated, drh_19.resource_id
  • Index Cond: ((drh_19.device_id = customer_device_history.device_id) AND (drh_19.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_19.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_19.updated >= customer_device_history.assigned) AND (drh_19.updated <= customer_device_history.unassigned))
125. 0.000 0.000 ↓ 0.0 0

Hash (cost=6.63..6.63 rows=18 width=16) (never executed)

  • Output: r_3.id, r_3.resource_meta_id, r_3.resource_group_id, u0_3.primary_resource_id
126. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=3.06..6.63 rows=18 width=16) (never executed)

  • Output: r_3.id, r_3.resource_meta_id, r_3.resource_group_id, u0_3.primary_resource_id
  • Hash Cond: (r_3.id = u0_3.primary_resource_id)
127. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource r_3 (cost=0.00..3.04 rows=104 width=12) (never executed)

  • Output: r_3.id, r_3.resource_meta_id, r_3.resource_group_id, r_3.measurement, r_3.field_name, r_3.created, r_3.updated, r_3.deleted
128. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.83..2.83 rows=18 width=4) (never executed)

  • Output: u0_3.primary_resource_id
129. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=2.65..2.83 rows=18 width=4) (never executed)

  • Output: u0_3.primary_resource_id
  • Group Key: u0_3.primary_resource_id
130. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type u0_3 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: u0_3.primary_resource_id
131. 0.000 0.000 ↓ 0.0 0

Index Scan using resource_meta_pkey on public.resource_meta rm_3 (cost=0.14..5.24 rows=1 width=162) (never executed)

  • Output: rm_3.id, rm_3.resource_group_meta_id, rm_3.code, rm_3.description, rm_3.value_type, rm_3.unit_of_measure, rm_3.attributes, rm_3.created, rm_3.updated, rm_3.deleted
  • Index Cond: (rm_3.id = r_3.resource_meta_id)
132. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group rg_3 (cost=0.00..1.29 rows=29 width=8) (never executed)

  • Output: rg_3.id, rg_3.resource_group_meta_id, rg_3.code, rg_3.description, rg_3.created, rg_3.updated, rg_3.deleted
133. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group_meta rgm_3 (cost=0.00..1.31 rows=31 width=4) (never executed)

  • Output: rgm_3.id, rgm_3.code, rgm_3.description, rgm_3.created, rgm_3.updated, rgm_3.deleted
134. 0.000 0.000 ↓ 0.0 0

Index Scan using device_pkey on public.device d_4 (cost=0.29..8.30 rows=1 width=8) (never executed)

  • Output: d_4.id, d_4.active, d_4.eid, d_4.entity_id, d_4.address_id, d_4.device_type_id, d_4.device_group_id, d_4.parent_id, d_4.communication_status_id, d_4.last_seen, d_4.created, d_4.updated, d_4.deleted, d_4.update_user_id, d_4.installed, d_4.application_profile_id, d_4.serial, d_4.first_seen, d_4.radio_id
  • Index Cond: (d_4.id = customer_device_history.device_id)
135. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type dt_3 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: dt_3.id, dt_3.name, dt_3.description, dt_3.created, dt_3.updated, dt_3.deleted, dt_3.update_user_id, dt_3.code, dt_3.primary_resource_id, dt_3.device_category_id, dt_3.active, dt_3.market, dt_3.default_application_profile_id, dt_3.status_policy, dt_3.has_meterage
136. 0.300 46.500 ↑ 1.0 1 100

Limit (cost=43.01..43.02 rows=1 width=8) (actual time=0.465..0.465 rows=1 loops=100)

  • Output: drh_20.updated
  • Buffers: shared hit=3363
137. 0.700 46.200 ↑ 1.0 1 100

Sort (cost=43.01..43.02 rows=1 width=8) (actual time=0.462..0.462 rows=1 loops=100)

  • Output: drh_20.updated
  • Sort Key: drh_20.updated DESC
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=3363
138. 0.969 45.500 ↓ 4.0 4 100

Nested Loop (cost=33.73..43.00 rows=1 width=8) (actual time=0.366..0.455 rows=4 loops=100)

  • Output: drh_20.updated
  • Buffers: shared hit=3363
139. 0.800 43.400 ↓ 4.0 4 100

Nested Loop (cost=33.59..37.76 rows=1 width=12) (actual time=0.361..0.434 rows=4 loops=100)

  • Output: drh_20.updated, r_4.resource_meta_id
  • Buffers: shared hit=2609
140. 3.300 6.900 ↑ 1.0 1 100

Hash Join (cost=8.32..11.04 rows=1 width=4) (actual time=0.024..0.069 rows=1 loops=100)

  • Output: d_5.id
  • Hash Cond: (dt_4.id = d_5.device_type_id)
  • Buffers: shared hit=500
141. 2.800 2.800 ↑ 1.0 52 100

Seq Scan on public.device_type dt_4 (cost=0.00..2.52 rows=52 width=4) (actual time=0.002..0.028 rows=52 loops=100)

  • Output: dt_4.id, dt_4.name, dt_4.description, dt_4.created, dt_4.updated, dt_4.deleted, dt_4.update_user_id, dt_4.code, dt_4.primary_resource_id, dt_4.device_category_id, dt_4.active, dt_4.market, dt_4.default_application_profile_id, dt_4.status_policy, dt_4.has_meterage
  • Buffers: shared hit=200
142. 0.300 0.800 ↑ 1.0 1 100

Hash (cost=8.30..8.30 rows=1 width=8) (actual time=0.008..0.008 rows=1 loops=100)

  • Output: d_5.id, d_5.device_type_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=300
143. 0.500 0.500 ↑ 1.0 1 100

Index Scan using device_pkey on public.device d_5 (cost=0.29..8.30 rows=1 width=8) (actual time=0.004..0.005 rows=1 loops=100)

  • Output: d_5.id, d_5.device_type_id
  • Index Cond: (d_5.id = customer_device_history.device_id)
  • Buffers: shared hit=300
144. 2.334 35.700 ↓ 4.0 4 100

Hash Join (cost=25.27..26.70 rows=1 width=16) (actual time=0.331..0.357 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.device_id, r_4.resource_meta_id
  • Hash Cond: (rgm_4.id = rg_4.resource_group_meta_id)
  • Buffers: shared hit=2109
145. 1.666 1.666 ↑ 1.0 31 98

Seq Scan on public.resource_group_meta rgm_4 (cost=0.00..1.31 rows=31 width=4) (actual time=0.001..0.017 rows=31 loops=98)

  • Output: rgm_4.id, rgm_4.code, rgm_4.description, rgm_4.created, rgm_4.updated, rgm_4.deleted
  • Buffers: shared hit=98
146. 0.400 31.700 ↓ 4.0 4 100

Hash (cost=25.26..25.26 rows=1 width=20) (actual time=0.317..0.317 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.device_id, r_4.resource_meta_id, rg_4.resource_group_meta_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2011
147. 6.845 31.300 ↓ 4.0 4 100

Nested Loop (cost=20.09..25.26 rows=1 width=20) (actual time=0.081..0.313 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.device_id, r_4.resource_meta_id, rg_4.resource_group_meta_id
  • Join Filter: (r_4.resource_group_id = rg_4.id)
  • Rows Removed by Join Filter: 106
  • Buffers: shared hit=2011
148. 0.696 18.800 ↓ 4.0 4 100

Hash Join (cost=20.09..23.60 rows=1 width=20) (actual time=0.077..0.188 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.device_id, r_4.resource_meta_id, r_4.resource_group_id
  • Hash Cond: (r_4.id = u0_4.primary_resource_id)
  • Buffers: shared hit=1634
149. 6.596 18.000 ↑ 1.2 4 100

Hash Join (cost=17.04..20.52 rows=5 width=28) (actual time=0.073..0.180 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.resource_id, drh_20.device_id, r_4.id, r_4.resource_meta_id, r_4.resource_group_id
  • Hash Cond: (r_4.id = drh_20.resource_id)
  • Buffers: shared hit=1632
150. 4.704 4.704 ↑ 1.0 104 98

Seq Scan on public.resource r_4 (cost=0.00..3.04 rows=104 width=12) (actual time=0.002..0.048 rows=104 loops=98)

  • Output: r_4.id, r_4.resource_meta_id, r_4.resource_group_id, r_4.measurement, r_4.field_name, r_4.created, r_4.updated, r_4.deleted
  • Buffers: shared hit=196
151. 0.500 6.700 ↑ 1.2 4 100

Hash (cost=16.98..16.98 rows=5 width=16) (actual time=0.067..0.067 rows=4 loops=100)

  • Output: drh_20.updated, drh_20.resource_id, drh_20.device_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=1436
152. 1.000 6.200 ↑ 1.2 4 100

Append (cost=0.00..16.98 rows=5 width=16) (actual time=0.055..0.062 rows=4 loops=100)

  • Buffers: shared hit=1436
153. 0.100 0.100 ↓ 0.0 0 100

Seq Scan on public.device_resource_history drh_20 (cost=0.00..0.00 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=100)

  • Output: drh_20.updated, drh_20.resource_id, drh_20.device_id
  • Filter: ((drh_20.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_20.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_20.updated >= customer_device_history.assigned) AND (drh_20.device_id = customer_device_history.device_id))
154. 0.400 0.400 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_21 (cost=0.00..1.16 rows=1 width=16) (actual time=0.004..0.004 rows=0 loops=100)

  • Output: drh_21.updated, drh_21.resource_id, drh_21.device_id
  • Filter: ((drh_21.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_21.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_21.updated >= customer_device_history.assigned) AND (drh_21.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 8
  • Buffers: shared hit=100
155. 1.600 1.600 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_22 (cost=0.00..3.06 rows=1 width=16) (actual time=0.016..0.016 rows=0 loops=100)

  • Output: drh_22.updated, drh_22.resource_id, drh_22.device_id
  • Filter: ((drh_22.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_22.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_22.updated >= customer_device_history.assigned) AND (drh_22.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 53
  • Buffers: shared hit=200
156. 2.300 2.300 ↓ 0.0 0 100

Index Only Scan Backward using _hyper_6_162_chunk_device_resource_history_updated_device_id_re on _timescaledb_internal._hyper_6_162_chunk drh_23 (cost=0.27..4.31 rows=1 width=16) (actual time=0.023..0.023 rows=0 loops=100)

  • Output: drh_23.updated, drh_23.resource_id, drh_23.device_id
  • Index Cond: ((drh_23.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_23.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_23.updated >= customer_device_history.assigned) AND (drh_23.device_id = customer_device_history.device_id))
  • Heap Fetches: 0
  • Buffers: shared hit=400
157. 0.800 0.800 ↓ 4.0 4 100

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_24 (cost=0.42..8.45 rows=1 width=16) (actual time=0.004..0.008 rows=4 loops=100)

  • Output: drh_24.updated, drh_24.resource_id, drh_24.device_id
  • Index Cond: ((drh_24.device_id = customer_device_history.device_id) AND (drh_24.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_24.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_24.updated >= customer_device_history.assigned))
  • Buffers: shared hit=736
158. 0.017 0.104 ↑ 1.0 18 1

Hash (cost=2.83..2.83 rows=18 width=4) (actual time=0.104..0.104 rows=18 loops=1)

  • Output: u0_4.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2
159. 0.050 0.087 ↓ 1.1 19 1

HashAggregate (cost=2.65..2.83 rows=18 width=4) (actual time=0.076..0.087 rows=19 loops=1)

  • Output: u0_4.primary_resource_id
  • Group Key: u0_4.primary_resource_id
  • Buffers: shared hit=2
160. 0.037 0.037 ↑ 1.0 52 1

Seq Scan on public.device_type u0_4 (cost=0.00..2.52 rows=52 width=4) (actual time=0.003..0.037 rows=52 loops=1)

  • Output: u0_4.primary_resource_id
  • Buffers: shared hit=2
161. 5.655 5.655 ↑ 1.0 29 377

Seq Scan on public.resource_group rg_4 (cost=0.00..1.29 rows=29 width=8) (actual time=0.001..0.015 rows=29 loops=377)

  • Output: rg_4.id, rg_4.resource_group_meta_id, rg_4.code, rg_4.description, rg_4.created, rg_4.updated, rg_4.deleted
  • Buffers: shared hit=377
162. 1.131 1.131 ↑ 1.0 1 377

Index Only Scan using resource_meta_pkey on public.resource_meta rm_4 (cost=0.14..5.24 rows=1 width=4) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: rm_4.id
  • Index Cond: (rm_4.id = r_4.resource_meta_id)
  • Heap Fetches: 377
  • Buffers: shared hit=754
163. 0.000 0.000 ↓ 0.0 0

Limit (cost=43.17..43.18 rows=1 width=8) (never executed)

  • Output: drh_25.updated
164. 0.000 0.000 ↓ 0.0 0

Sort (cost=43.17..43.18 rows=1 width=8) (never executed)

  • Output: drh_25.updated
  • Sort Key: drh_25.updated DESC
165. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=33.89..43.16 rows=1 width=8) (never executed)

  • Output: drh_25.updated
166. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=33.75..37.92 rows=1 width=12) (never executed)

  • Output: drh_25.updated, r_5.resource_meta_id
167. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=8.32..11.04 rows=1 width=4) (never executed)

  • Output: d_6.id
  • Hash Cond: (dt_5.id = d_6.device_type_id)
168. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type dt_5 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: dt_5.id, dt_5.name, dt_5.description, dt_5.created, dt_5.updated, dt_5.deleted, dt_5.update_user_id, dt_5.code, dt_5.primary_resource_id, dt_5.device_category_id, dt_5.active, dt_5.market, dt_5.default_application_profile_id, dt_5.status_policy, dt_5.has_meterage
169. 0.000 0.000 ↓ 0.0 0

Hash (cost=8.30..8.30 rows=1 width=8) (never executed)

  • Output: d_6.id, d_6.device_type_id
170. 0.000 0.000 ↓ 0.0 0

Index Scan using device_pkey on public.device d_6 (cost=0.29..8.30 rows=1 width=8) (never executed)

  • Output: d_6.id, d_6.device_type_id
  • Index Cond: (d_6.id = customer_device_history.device_id)
171. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=25.43..26.87 rows=1 width=16) (never executed)

  • Output: drh_25.updated, drh_25.device_id, r_5.resource_meta_id
  • Hash Cond: (rgm_5.id = rg_5.resource_group_meta_id)
172. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group_meta rgm_5 (cost=0.00..1.31 rows=31 width=4) (never executed)

  • Output: rgm_5.id, rgm_5.code, rgm_5.description, rgm_5.created, rgm_5.updated, rgm_5.deleted
173. 0.000 0.000 ↓ 0.0 0

Hash (cost=25.42..25.42 rows=1 width=20) (never executed)

  • Output: drh_25.updated, drh_25.device_id, r_5.resource_meta_id, rg_5.resource_group_meta_id
174. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=20.26..25.42 rows=1 width=20) (never executed)

  • Output: drh_25.updated, drh_25.device_id, r_5.resource_meta_id, rg_5.resource_group_meta_id
  • Join Filter: (r_5.resource_group_id = rg_5.id)
175. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=20.26..23.76 rows=1 width=20) (never executed)

  • Output: drh_25.updated, drh_25.device_id, r_5.resource_meta_id, r_5.resource_group_id
  • Hash Cond: (r_5.id = u0_5.primary_resource_id)
176. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=17.20..20.68 rows=5 width=28) (never executed)

  • Output: drh_25.updated, drh_25.resource_id, drh_25.device_id, r_5.id, r_5.resource_meta_id, r_5.resource_group_id
  • Hash Cond: (r_5.id = drh_25.resource_id)
177. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource r_5 (cost=0.00..3.04 rows=104 width=12) (never executed)

  • Output: r_5.id, r_5.resource_meta_id, r_5.resource_group_id, r_5.measurement, r_5.field_name, r_5.created, r_5.updated, r_5.deleted
178. 0.000 0.000 ↓ 0.0 0

Hash (cost=17.14..17.14 rows=5 width=16) (never executed)

  • Output: drh_25.updated, drh_25.resource_id, drh_25.device_id
179. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..17.14 rows=5 width=16) (never executed)

180. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_resource_history drh_25 (cost=0.00..0.00 rows=1 width=16) (never executed)

  • Output: drh_25.updated, drh_25.resource_id, drh_25.device_id
  • Filter: ((drh_25.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_25.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_25.updated >= customer_device_history.assigned) AND (drh_25.updated <= customer_device_history.unassigned) AND (drh_25.device_id = customer_device_history.device_id))
181. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_26 (cost=0.00..1.18 rows=1 width=16) (never executed)

  • Output: drh_26.updated, drh_26.resource_id, drh_26.device_id
  • Filter: ((drh_26.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_26.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_26.updated >= customer_device_history.assigned) AND (drh_26.updated <= customer_device_history.unassigned) AND (drh_26.device_id = customer_device_history.device_id))
182. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_27 (cost=0.00..3.19 rows=1 width=16) (never executed)

  • Output: drh_27.updated, drh_27.resource_id, drh_27.device_id
  • Filter: ((drh_27.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_27.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_27.updated >= customer_device_history.assigned) AND (drh_27.updated <= customer_device_history.unassigned) AND (drh_27.device_id = customer_device_history.device_id))
183. 0.000 0.000 ↓ 0.0 0

Index Only Scan Backward using _hyper_6_162_chunk_device_resource_history_updated_device_id_re on _timescaledb_internal._hyper_6_162_chunk drh_28 (cost=0.27..4.32 rows=1 width=16) (never executed)

  • Output: drh_28.updated, drh_28.resource_id, drh_28.device_id
  • Index Cond: ((drh_28.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_28.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_28.updated >= customer_device_history.assigned) AND (drh_28.updated <= customer_device_history.unassigned) AND (drh_28.device_id = customer_device_history.device_id))
  • Heap Fetches: 0
184. 0.000 0.000 ↓ 0.0 0

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_29 (cost=0.42..8.45 rows=1 width=16) (never executed)

  • Output: drh_29.updated, drh_29.resource_id, drh_29.device_id
  • Index Cond: ((drh_29.device_id = customer_device_history.device_id) AND (drh_29.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_29.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_29.updated >= customer_device_history.assigned) AND (drh_29.updated <= customer_device_history.unassigned))
185. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.83..2.83 rows=18 width=4) (never executed)

  • Output: u0_5.primary_resource_id
186. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=2.65..2.83 rows=18 width=4) (never executed)

  • Output: u0_5.primary_resource_id
  • Group Key: u0_5.primary_resource_id
187. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type u0_5 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: u0_5.primary_resource_id
188. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group rg_5 (cost=0.00..1.29 rows=29 width=8) (never executed)

  • Output: rg_5.id, rg_5.resource_group_meta_id, rg_5.code, rg_5.description, rg_5.created, rg_5.updated, rg_5.deleted
189. 0.000 0.000 ↓ 0.0 0

Index Only Scan using resource_meta_pkey on public.resource_meta rm_5 (cost=0.14..5.24 rows=1 width=4) (never executed)

  • Output: rm_5.id
  • Index Cond: (rm_5.id = r_5.resource_meta_id)
  • Heap Fetches: 0
190. 0.100 65.700 ↑ 1.0 1 100

Limit (cost=47.62..47.90 rows=1 width=40) (actual time=0.657..0.657 rows=1 loops=100)

  • Output: (CASE WHEN (drh_30.calculated IS NOT NULL) THEN drh_30.calculated_value ELSE (CASE WHEN ((rm_6.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_30.device_id, rm_6.attributes, drh_30.value, drh_30.updated) ELSE ((drh_30.value)::text)::numeric END * COALESCE(((rm_6.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_30.updated
  • Buffers: shared hit=4933
191. 0.300 65.600 ↑ 1.0 1 100

Result (cost=47.62..47.90 rows=1 width=40) (actual time=0.656..0.656 rows=1 loops=100)

  • Output: CASE WHEN (drh_30.calculated IS NOT NULL) THEN drh_30.calculated_value ELSE (CASE WHEN ((rm_6.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_30.device_id, rm_6.attributes, drh_30.value, drh_30.updated) ELSE ((drh_30.value)::text)::numeric END * COALESCE(((rm_6.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_30.updated
  • Buffers: shared hit=4933
192. 0.900 65.300 ↑ 1.0 1 100

Sort (cost=47.62..47.62 rows=1 width=209) (actual time=0.653..0.653 rows=1 loops=100)

  • Output: drh_30.updated, drh_30.calculated, drh_30.calculated_value, rm_6.attributes, drh_30.device_id, drh_30.value
  • Sort Key: drh_30.updated DESC
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=4933
193. 11.321 64.400 ↓ 4.0 4 100

Nested Loop (cost=7.29..47.61 rows=1 width=209) (actual time=0.154..0.644 rows=4 loops=100)

  • Output: drh_30.updated, drh_30.calculated, drh_30.calculated_value, rm_6.attributes, drh_30.device_id, drh_30.value
  • Join Filter: (d_7.device_type_id = dt_6.id)
  • Rows Removed by Join Filter: 192
  • Buffers: shared hit=4933
194. 0.969 42.900 ↓ 4.0 4 100

Nested Loop (cost=7.29..44.44 rows=1 width=213) (actual time=0.141..0.429 rows=4 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, rm_6.attributes, d_7.device_type_id
  • Buffers: shared hit=4179
195. 7.268 40.800 ↓ 4.0 4 100

Nested Loop (cost=7.00..36.12 rows=1 width=209) (actual time=0.136..0.408 rows=4 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, rm_6.attributes
  • Join Filter: (rg_6.resource_group_meta_id = rgm_6.id)
  • Rows Removed by Join Filter: 113
  • Buffers: shared hit=3048
196. 6.945 27.500 ↓ 4.0 4 100

Nested Loop (cost=7.00..34.42 rows=1 width=213) (actual time=0.124..0.275 rows=4 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, rm_6.attributes, rg_6.resource_group_meta_id
  • Join Filter: (r_6.resource_group_id = rg_6.id)
  • Rows Removed by Join Filter: 106
  • Buffers: shared hit=2671
197. 0.869 14.900 ↓ 4.0 4 100

Nested Loop (cost=7.00..32.77 rows=1 width=213) (actual time=0.120..0.149 rows=4 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, r_6.resource_group_id, rm_6.attributes
  • Buffers: shared hit=2294
198. 0.850 12.900 ↓ 4.0 4 100

Hash Join (cost=6.86..27.52 rows=1 width=59) (actual time=0.115..0.129 rows=4 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, r_6.resource_meta_id, r_6.resource_group_id
  • Hash Cond: (drh_30.resource_id = r_6.id)
  • Buffers: shared hit=1540
199. 1.200 11.800 ↑ 1.2 4 100

Append (cost=0.00..20.64 rows=5 width=55) (actual time=0.110..0.118 rows=4 loops=100)

  • Buffers: shared hit=1536
200. 0.100 0.100 ↓ 0.0 0 100

Seq Scan on public.device_resource_history drh_30 (cost=0.00..0.00 rows=1 width=88) (actual time=0.001..0.001 rows=0 loops=100)

  • Output: drh_30.calculated, drh_30.calculated_value, drh_30.device_id, drh_30.value, drh_30.updated, drh_30.resource_id
  • Filter: ((drh_30.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_30.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_30.updated >= customer_device_history.assigned) AND (drh_30.device_id = customer_device_history.device_id))
201. 0.400 0.400 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_31 (cost=0.00..1.16 rows=1 width=46) (actual time=0.004..0.004 rows=0 loops=100)

  • Output: drh_31.calculated, drh_31.calculated_value, drh_31.device_id, drh_31.value, drh_31.updated, drh_31.resource_id
  • Filter: ((drh_31.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_31.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_31.updated >= customer_device_history.assigned) AND (drh_31.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 8
  • Buffers: shared hit=100
202. 1.600 1.600 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_32 (cost=0.00..3.06 rows=1 width=46) (actual time=0.016..0.016 rows=0 loops=100)

  • Output: drh_32.calculated, drh_32.calculated_value, drh_32.device_id, drh_32.value, drh_32.updated, drh_32.resource_id
  • Filter: ((drh_32.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_32.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_32.updated >= customer_device_history.assigned) AND (drh_32.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 53
  • Buffers: shared hit=200
203. 4.800 7.700 ↓ 0.0 0 100

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_33 (cost=4.17..7.97 rows=1 width=49) (actual time=0.077..0.077 rows=0 loops=100)

  • Output: drh_33.calculated, drh_33.calculated_value, drh_33.device_id, drh_33.value, drh_33.updated, drh_33.resource_id
  • Recheck Cond: ((drh_33.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_33.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_33.updated >= customer_device_history.assigned))
  • Filter: (drh_33.device_id = customer_device_history.device_id)
  • Rows Removed by Filter: 364
  • Heap Blocks: exact=400
  • Buffers: shared hit=500
204. 2.900 2.900 ↓ 182.0 364 100

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.17 rows=2 width=0) (actual time=0.029..0.029 rows=364 loops=100)

  • Index Cond: ((drh_33.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_33.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_33.updated >= customer_device_history.assigned))
  • Buffers: shared hit=100
205. 0.800 0.800 ↓ 4.0 4 100

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_34 (cost=0.42..8.45 rows=1 width=48) (actual time=0.004..0.008 rows=4 loops=100)

  • Output: drh_34.calculated, drh_34.calculated_value, drh_34.device_id, drh_34.value, drh_34.updated, drh_34.resource_id
  • Index Cond: ((drh_34.device_id = customer_device_history.device_id) AND (drh_34.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_34.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_34.updated >= customer_device_history.assigned))
  • Buffers: shared hit=736
206. 0.020 0.250 ↑ 1.0 18 1

Hash (cost=6.63..6.63 rows=18 width=16) (actual time=0.250..0.250 rows=18 loops=1)

  • Output: r_6.id, r_6.resource_meta_id, r_6.resource_group_id, u0_6.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=4
207. 0.104 0.230 ↑ 1.0 18 1

Hash Join (cost=3.06..6.63 rows=18 width=16) (actual time=0.110..0.230 rows=18 loops=1)

  • Output: r_6.id, r_6.resource_meta_id, r_6.resource_group_id, u0_6.primary_resource_id
  • Hash Cond: (r_6.id = u0_6.primary_resource_id)
  • Buffers: shared hit=4
208. 0.031 0.031 ↑ 1.0 104 1

Seq Scan on public.resource r_6 (cost=0.00..3.04 rows=104 width=12) (actual time=0.004..0.031 rows=104 loops=1)

  • Output: r_6.id, r_6.resource_meta_id, r_6.resource_group_id, r_6.measurement, r_6.field_name, r_6.created, r_6.updated, r_6.deleted
  • Buffers: shared hit=2
209. 0.014 0.095 ↑ 1.0 18 1

Hash (cost=2.83..2.83 rows=18 width=4) (actual time=0.095..0.095 rows=18 loops=1)

  • Output: u0_6.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2
210. 0.047 0.081 ↓ 1.1 19 1

HashAggregate (cost=2.65..2.83 rows=18 width=4) (actual time=0.070..0.081 rows=19 loops=1)

  • Output: u0_6.primary_resource_id
  • Group Key: u0_6.primary_resource_id
  • Buffers: shared hit=2
211. 0.034 0.034 ↑ 1.0 52 1

Seq Scan on public.device_type u0_6 (cost=0.00..2.52 rows=52 width=4) (actual time=0.003..0.034 rows=52 loops=1)

  • Output: u0_6.primary_resource_id
  • Buffers: shared hit=2
212. 1.131 1.131 ↑ 1.0 1 377

Index Scan using resource_meta_pkey on public.resource_meta rm_6 (cost=0.14..5.24 rows=1 width=162) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: rm_6.id, rm_6.resource_group_meta_id, rm_6.code, rm_6.description, rm_6.value_type, rm_6.unit_of_measure, rm_6.attributes, rm_6.created, rm_6.updated, rm_6.deleted
  • Index Cond: (rm_6.id = r_6.resource_meta_id)
  • Buffers: shared hit=754
213. 5.655 5.655 ↑ 1.0 29 377

Seq Scan on public.resource_group rg_6 (cost=0.00..1.29 rows=29 width=8) (actual time=0.001..0.015 rows=29 loops=377)

  • Output: rg_6.id, rg_6.resource_group_meta_id, rg_6.code, rg_6.description, rg_6.created, rg_6.updated, rg_6.deleted
  • Buffers: shared hit=377
214. 6.032 6.032 ↑ 1.0 31 377

Seq Scan on public.resource_group_meta rgm_6 (cost=0.00..1.31 rows=31 width=4) (actual time=0.001..0.016 rows=31 loops=377)

  • Output: rgm_6.id, rgm_6.code, rgm_6.description, rgm_6.created, rgm_6.updated, rgm_6.deleted
  • Buffers: shared hit=377
215. 1.131 1.131 ↑ 1.0 1 377

Index Scan using device_pkey on public.device d_7 (cost=0.29..8.30 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: d_7.id, d_7.active, d_7.eid, d_7.entity_id, d_7.address_id, d_7.device_type_id, d_7.device_group_id, d_7.parent_id, d_7.communication_status_id, d_7.last_seen, d_7.created, d_7.updated, d_7.deleted, d_7.update_user_id, d_7.installed, d_7.application_profile_id, d_7.serial, d_7.first_seen, d_7.radio_id
  • Index Cond: (d_7.id = customer_device_history.device_id)
  • Buffers: shared hit=1131
216. 10.179 10.179 ↑ 1.0 52 377

Seq Scan on public.device_type dt_6 (cost=0.00..2.52 rows=52 width=4) (actual time=0.001..0.027 rows=52 loops=377)

  • Output: dt_6.id, dt_6.name, dt_6.description, dt_6.created, dt_6.updated, dt_6.deleted, dt_6.update_user_id, dt_6.code, dt_6.primary_resource_id, dt_6.device_category_id, dt_6.active, dt_6.market, dt_6.default_application_profile_id, dt_6.status_policy, dt_6.has_meterage
  • Buffers: shared hit=754
217. 0.000 0.000 ↓ 0.0 0

Limit (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: (CASE WHEN (drh_35.calculated IS NOT NULL) THEN drh_35.calculated_value ELSE (CASE WHEN ((rm_7.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_35.device_id, rm_7.attributes, drh_35.value, drh_35.updated) ELSE ((drh_35.value)::text)::numeric END * COALESCE(((rm_7.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_35.updated
218. 0.000 0.000 ↓ 0.0 0

Result (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: CASE WHEN (drh_35.calculated IS NOT NULL) THEN drh_35.calculated_value ELSE (CASE WHEN ((rm_7.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_35.device_id, rm_7.attributes, drh_35.value, drh_35.updated) ELSE ((drh_35.value)::text)::numeric END * COALESCE(((rm_7.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_35.updated
219. 0.000 0.000 ↓ 0.0 0

Sort (cost=47.78..47.79 rows=1 width=209) (never executed)

  • Output: drh_35.updated, drh_35.calculated, drh_35.calculated_value, rm_7.attributes, drh_35.device_id, drh_35.value
  • Sort Key: drh_35.updated DESC
220. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..47.77 rows=1 width=209) (never executed)

  • Output: drh_35.updated, drh_35.calculated, drh_35.calculated_value, rm_7.attributes, drh_35.device_id, drh_35.value
  • Join Filter: (d_8.device_type_id = dt_7.id)
221. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..44.60 rows=1 width=213) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, rm_7.attributes, d_8.device_type_id
222. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..36.29 rows=1 width=209) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, rm_7.attributes
  • Join Filter: (rg_7.resource_group_meta_id = rgm_7.id)
223. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..34.59 rows=1 width=213) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, rm_7.attributes, rg_7.resource_group_meta_id
  • Join Filter: (r_7.resource_group_id = rg_7.id)
224. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..32.94 rows=1 width=213) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, r_7.resource_group_id, rm_7.attributes
225. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=6.86..27.69 rows=1 width=59) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, r_7.resource_meta_id, r_7.resource_group_id
  • Hash Cond: (drh_35.resource_id = r_7.id)
226. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..20.80 rows=5 width=55) (never executed)

227. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_resource_history drh_35 (cost=0.00..0.00 rows=1 width=88) (never executed)

  • Output: drh_35.calculated, drh_35.calculated_value, drh_35.device_id, drh_35.value, drh_35.updated, drh_35.resource_id
  • Filter: ((drh_35.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_35.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_35.updated >= customer_device_history.assigned) AND (drh_35.updated <= customer_device_history.unassigned) AND (drh_35.device_id = customer_device_history.device_id))
228. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_36 (cost=0.00..1.18 rows=1 width=46) (never executed)

  • Output: drh_36.calculated, drh_36.calculated_value, drh_36.device_id, drh_36.value, drh_36.updated, drh_36.resource_id
  • Filter: ((drh_36.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_36.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_36.updated >= customer_device_history.assigned) AND (drh_36.updated <= customer_device_history.unassigned) AND (drh_36.device_id = customer_device_history.device_id))
229. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_37 (cost=0.00..3.19 rows=1 width=46) (never executed)

  • Output: drh_37.calculated, drh_37.calculated_value, drh_37.device_id, drh_37.value, drh_37.updated, drh_37.resource_id
  • Filter: ((drh_37.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_37.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_37.updated >= customer_device_history.assigned) AND (drh_37.updated <= customer_device_history.unassigned) AND (drh_37.device_id = customer_device_history.device_id))
230. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_38 (cost=4.18..7.98 rows=1 width=49) (never executed)

  • Output: drh_38.calculated, drh_38.calculated_value, drh_38.device_id, drh_38.value, drh_38.updated, drh_38.resource_id
  • Recheck Cond: ((drh_38.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_38.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_38.updated >= customer_device_history.assigned) AND (drh_38.updated <= customer_device_history.unassigned))
  • Filter: (drh_38.device_id = customer_device_history.device_id)
231. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.18 rows=2 width=0) (never executed)

  • Index Cond: ((drh_38.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_38.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_38.updated >= customer_device_history.assigned) AND (drh_38.updated <= customer_device_history.unassigned))
232. 0.000 0.000 ↓ 0.0 0

Index Scan Backward using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_39 (cost=0.42..8.45 rows=1 width=48) (never executed)

  • Output: drh_39.calculated, drh_39.calculated_value, drh_39.device_id, drh_39.value, drh_39.updated, drh_39.resource_id
  • Index Cond: ((drh_39.device_id = customer_device_history.device_id) AND (drh_39.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_39.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_39.updated >= customer_device_history.assigned) AND (drh_39.updated <= customer_device_history.unassigned))
233. 0.000 0.000 ↓ 0.0 0

Hash (cost=6.63..6.63 rows=18 width=16) (never executed)

  • Output: r_7.id, r_7.resource_meta_id, r_7.resource_group_id, u0_7.primary_resource_id
234. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=3.06..6.63 rows=18 width=16) (never executed)

  • Output: r_7.id, r_7.resource_meta_id, r_7.resource_group_id, u0_7.primary_resource_id
  • Hash Cond: (r_7.id = u0_7.primary_resource_id)
235. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource r_7 (cost=0.00..3.04 rows=104 width=12) (never executed)

  • Output: r_7.id, r_7.resource_meta_id, r_7.resource_group_id, r_7.measurement, r_7.field_name, r_7.created, r_7.updated, r_7.deleted
236. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.83..2.83 rows=18 width=4) (never executed)

  • Output: u0_7.primary_resource_id
237. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=2.65..2.83 rows=18 width=4) (never executed)

  • Output: u0_7.primary_resource_id
  • Group Key: u0_7.primary_resource_id
238. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type u0_7 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: u0_7.primary_resource_id
239. 0.000 0.000 ↓ 0.0 0

Index Scan using resource_meta_pkey on public.resource_meta rm_7 (cost=0.14..5.24 rows=1 width=162) (never executed)

  • Output: rm_7.id, rm_7.resource_group_meta_id, rm_7.code, rm_7.description, rm_7.value_type, rm_7.unit_of_measure, rm_7.attributes, rm_7.created, rm_7.updated, rm_7.deleted
  • Index Cond: (rm_7.id = r_7.resource_meta_id)
240. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group rg_7 (cost=0.00..1.29 rows=29 width=8) (never executed)

  • Output: rg_7.id, rg_7.resource_group_meta_id, rg_7.code, rg_7.description, rg_7.created, rg_7.updated, rg_7.deleted
241. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group_meta rgm_7 (cost=0.00..1.31 rows=31 width=4) (never executed)

  • Output: rgm_7.id, rgm_7.code, rgm_7.description, rgm_7.created, rgm_7.updated, rgm_7.deleted
242. 0.000 0.000 ↓ 0.0 0

Index Scan using device_pkey on public.device d_8 (cost=0.29..8.30 rows=1 width=8) (never executed)

  • Output: d_8.id, d_8.active, d_8.eid, d_8.entity_id, d_8.address_id, d_8.device_type_id, d_8.device_group_id, d_8.parent_id, d_8.communication_status_id, d_8.last_seen, d_8.created, d_8.updated, d_8.deleted, d_8.update_user_id, d_8.installed, d_8.application_profile_id, d_8.serial, d_8.first_seen, d_8.radio_id
  • Index Cond: (d_8.id = customer_device_history.device_id)
243. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type dt_7 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: dt_7.id, dt_7.name, dt_7.description, dt_7.created, dt_7.updated, dt_7.deleted, dt_7.update_user_id, dt_7.code, dt_7.primary_resource_id, dt_7.device_category_id, dt_7.active, dt_7.market, dt_7.default_application_profile_id, dt_7.status_policy, dt_7.has_meterage
244. 0.200 65.800 ↑ 1.0 1 100

Limit (cost=47.62..47.90 rows=1 width=40) (actual time=0.658..0.658 rows=1 loops=100)

  • Output: (CASE WHEN (drh_40.calculated IS NOT NULL) THEN drh_40.calculated_value ELSE (CASE WHEN ((rm_8.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_40.device_id, rm_8.attributes, drh_40.value, drh_40.updated) ELSE ((drh_40.value)::text)::numeric END * COALESCE(((rm_8.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_40.updated
  • Buffers: shared hit=4835
245. 0.200 65.600 ↑ 1.0 1 100

Result (cost=47.62..47.90 rows=1 width=40) (actual time=0.656..0.656 rows=1 loops=100)

  • Output: CASE WHEN (drh_40.calculated IS NOT NULL) THEN drh_40.calculated_value ELSE (CASE WHEN ((rm_8.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_40.device_id, rm_8.attributes, drh_40.value, drh_40.updated) ELSE ((drh_40.value)::text)::numeric END * COALESCE(((rm_8.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_40.updated
  • Buffers: shared hit=4835
246. 1.000 65.400 ↑ 1.0 1 100

Sort (cost=47.62..47.62 rows=1 width=209) (actual time=0.654..0.654 rows=1 loops=100)

  • Output: drh_40.updated, drh_40.calculated, drh_40.calculated_value, rm_8.attributes, drh_40.device_id, drh_40.value
  • Sort Key: drh_40.updated
  • Sort Method: top-N heapsort Memory: 25kB
  • Buffers: shared hit=4835
247. 11.044 64.400 ↓ 4.0 4 100

Nested Loop (cost=7.29..47.61 rows=1 width=209) (actual time=0.154..0.644 rows=4 loops=100)

  • Output: drh_40.updated, drh_40.calculated, drh_40.calculated_value, rm_8.attributes, drh_40.device_id, drh_40.value
  • Join Filter: (d_9.device_type_id = dt_8.id)
  • Rows Removed by Join Filter: 192
  • Buffers: shared hit=4835
248. 0.969 42.800 ↓ 4.0 4 100

Nested Loop (cost=7.29..44.44 rows=1 width=213) (actual time=0.141..0.428 rows=4 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, rm_8.attributes, d_9.device_type_id
  • Buffers: shared hit=4081
249. 6.791 40.700 ↓ 4.0 4 100

Nested Loop (cost=7.00..36.12 rows=1 width=209) (actual time=0.136..0.407 rows=4 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, rm_8.attributes
  • Join Filter: (rg_8.resource_group_meta_id = rgm_8.id)
  • Rows Removed by Join Filter: 113
  • Buffers: shared hit=2950
250. 6.945 27.500 ↓ 4.0 4 100

Nested Loop (cost=7.00..34.42 rows=1 width=213) (actual time=0.124..0.275 rows=4 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, rm_8.attributes, rg_8.resource_group_meta_id
  • Join Filter: (r_8.resource_group_id = rg_8.id)
  • Rows Removed by Join Filter: 106
  • Buffers: shared hit=2573
251. 0.969 14.900 ↓ 4.0 4 100

Nested Loop (cost=7.00..32.77 rows=1 width=213) (actual time=0.120..0.149 rows=4 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, r_8.resource_group_id, rm_8.attributes
  • Buffers: shared hit=2196
252. 0.750 12.800 ↓ 4.0 4 100

Hash Join (cost=6.86..27.52 rows=1 width=59) (actual time=0.115..0.128 rows=4 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, r_8.resource_meta_id, r_8.resource_group_id
  • Hash Cond: (drh_40.resource_id = r_8.id)
  • Buffers: shared hit=1442
253. 1.100 11.800 ↑ 1.2 4 100

Append (cost=0.00..20.64 rows=5 width=55) (actual time=0.110..0.118 rows=4 loops=100)

  • Buffers: shared hit=1438
254. 0.100 0.100 ↓ 0.0 0 100

Seq Scan on public.device_resource_history drh_40 (cost=0.00..0.00 rows=1 width=88) (actual time=0.001..0.001 rows=0 loops=100)

  • Output: drh_40.calculated, drh_40.calculated_value, drh_40.device_id, drh_40.value, drh_40.updated, drh_40.resource_id
  • Filter: ((drh_40.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_40.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_40.updated >= customer_device_history.assigned) AND (drh_40.device_id = customer_device_history.device_id))
255. 0.500 0.500 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_41 (cost=0.00..1.16 rows=1 width=46) (actual time=0.005..0.005 rows=0 loops=100)

  • Output: drh_41.calculated, drh_41.calculated_value, drh_41.device_id, drh_41.value, drh_41.updated, drh_41.resource_id
  • Filter: ((drh_41.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_41.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_41.updated >= customer_device_history.assigned) AND (drh_41.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 8
  • Buffers: shared hit=100
256. 1.600 1.600 ↓ 0.0 0 100

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_42 (cost=0.00..3.06 rows=1 width=46) (actual time=0.016..0.016 rows=0 loops=100)

  • Output: drh_42.calculated, drh_42.calculated_value, drh_42.device_id, drh_42.value, drh_42.updated, drh_42.resource_id
  • Filter: ((drh_42.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_42.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_42.updated >= customer_device_history.assigned) AND (drh_42.device_id = customer_device_history.device_id))
  • Rows Removed by Filter: 53
  • Buffers: shared hit=200
257. 4.800 7.700 ↓ 0.0 0 100

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_43 (cost=4.17..7.97 rows=1 width=49) (actual time=0.077..0.077 rows=0 loops=100)

  • Output: drh_43.calculated, drh_43.calculated_value, drh_43.device_id, drh_43.value, drh_43.updated, drh_43.resource_id
  • Recheck Cond: ((drh_43.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_43.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_43.updated >= customer_device_history.assigned))
  • Filter: (drh_43.device_id = customer_device_history.device_id)
  • Rows Removed by Filter: 364
  • Heap Blocks: exact=400
  • Buffers: shared hit=500
258. 2.900 2.900 ↓ 182.0 364 100

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.17 rows=2 width=0) (actual time=0.029..0.029 rows=364 loops=100)

  • Index Cond: ((drh_43.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_43.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_43.updated >= customer_device_history.assigned))
  • Buffers: shared hit=100
259. 0.800 0.800 ↓ 4.0 4 100

Index Scan using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_44 (cost=0.42..8.45 rows=1 width=48) (actual time=0.004..0.008 rows=4 loops=100)

  • Output: drh_44.calculated, drh_44.calculated_value, drh_44.device_id, drh_44.value, drh_44.updated, drh_44.resource_id
  • Index Cond: ((drh_44.device_id = customer_device_history.device_id) AND (drh_44.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_44.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_44.updated >= customer_device_history.assigned))
  • Buffers: shared hit=638
260. 0.017 0.250 ↑ 1.0 18 1

Hash (cost=6.63..6.63 rows=18 width=16) (actual time=0.250..0.250 rows=18 loops=1)

  • Output: r_8.id, r_8.resource_meta_id, r_8.resource_group_id, u0_8.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=4
261. 0.091 0.233 ↑ 1.0 18 1

Hash Join (cost=3.06..6.63 rows=18 width=16) (actual time=0.115..0.233 rows=18 loops=1)

  • Output: r_8.id, r_8.resource_meta_id, r_8.resource_group_id, u0_8.primary_resource_id
  • Hash Cond: (r_8.id = u0_8.primary_resource_id)
  • Buffers: shared hit=4
262. 0.047 0.047 ↑ 1.0 104 1

Seq Scan on public.resource r_8 (cost=0.00..3.04 rows=104 width=12) (actual time=0.004..0.047 rows=104 loops=1)

  • Output: r_8.id, r_8.resource_meta_id, r_8.resource_group_id, r_8.measurement, r_8.field_name, r_8.created, r_8.updated, r_8.deleted
  • Buffers: shared hit=2
263. 0.012 0.095 ↑ 1.0 18 1

Hash (cost=2.83..2.83 rows=18 width=4) (actual time=0.095..0.095 rows=18 loops=1)

  • Output: u0_8.primary_resource_id
  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=2
264. 0.049 0.083 ↓ 1.1 19 1

HashAggregate (cost=2.65..2.83 rows=18 width=4) (actual time=0.071..0.083 rows=19 loops=1)

  • Output: u0_8.primary_resource_id
  • Group Key: u0_8.primary_resource_id
  • Buffers: shared hit=2
265. 0.034 0.034 ↑ 1.0 52 1

Seq Scan on public.device_type u0_8 (cost=0.00..2.52 rows=52 width=4) (actual time=0.004..0.034 rows=52 loops=1)

  • Output: u0_8.primary_resource_id
  • Buffers: shared hit=2
266. 1.131 1.131 ↑ 1.0 1 377

Index Scan using resource_meta_pkey on public.resource_meta rm_8 (cost=0.14..5.24 rows=1 width=162) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: rm_8.id, rm_8.resource_group_meta_id, rm_8.code, rm_8.description, rm_8.value_type, rm_8.unit_of_measure, rm_8.attributes, rm_8.created, rm_8.updated, rm_8.deleted
  • Index Cond: (rm_8.id = r_8.resource_meta_id)
  • Buffers: shared hit=754
267. 5.655 5.655 ↑ 1.0 29 377

Seq Scan on public.resource_group rg_8 (cost=0.00..1.29 rows=29 width=8) (actual time=0.001..0.015 rows=29 loops=377)

  • Output: rg_8.id, rg_8.resource_group_meta_id, rg_8.code, rg_8.description, rg_8.created, rg_8.updated, rg_8.deleted
  • Buffers: shared hit=377
268. 6.409 6.409 ↑ 1.0 31 377

Seq Scan on public.resource_group_meta rgm_8 (cost=0.00..1.31 rows=31 width=4) (actual time=0.001..0.017 rows=31 loops=377)

  • Output: rgm_8.id, rgm_8.code, rgm_8.description, rgm_8.created, rgm_8.updated, rgm_8.deleted
  • Buffers: shared hit=377
269. 1.131 1.131 ↑ 1.0 1 377

Index Scan using device_pkey on public.device d_9 (cost=0.29..8.30 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=377)

  • Output: d_9.id, d_9.active, d_9.eid, d_9.entity_id, d_9.address_id, d_9.device_type_id, d_9.device_group_id, d_9.parent_id, d_9.communication_status_id, d_9.last_seen, d_9.created, d_9.updated, d_9.deleted, d_9.update_user_id, d_9.installed, d_9.application_profile_id, d_9.serial, d_9.first_seen, d_9.radio_id
  • Index Cond: (d_9.id = customer_device_history.device_id)
  • Buffers: shared hit=1131
270. 10.556 10.556 ↑ 1.0 52 377

Seq Scan on public.device_type dt_8 (cost=0.00..2.52 rows=52 width=4) (actual time=0.001..0.028 rows=52 loops=377)

  • Output: dt_8.id, dt_8.name, dt_8.description, dt_8.created, dt_8.updated, dt_8.deleted, dt_8.update_user_id, dt_8.code, dt_8.primary_resource_id, dt_8.device_category_id, dt_8.active, dt_8.market, dt_8.default_application_profile_id, dt_8.status_policy, dt_8.has_meterage
  • Buffers: shared hit=754
271. 0.000 0.000 ↓ 0.0 0

Limit (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: (CASE WHEN (drh_45.calculated IS NOT NULL) THEN drh_45.calculated_value ELSE (CASE WHEN ((rm_9.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_45.device_id, rm_9.attributes, drh_45.value, drh_45.updated) ELSE ((drh_45.value)::text)::numeric END * COALESCE(((rm_9.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END), drh_45.updated
272. 0.000 0.000 ↓ 0.0 0

Result (cost=47.78..48.07 rows=1 width=40) (never executed)

  • Output: CASE WHEN (drh_45.calculated IS NOT NULL) THEN drh_45.calculated_value ELSE (CASE WHEN ((rm_9.attributes ->> 'calculation'::text) IS NOT NULL) THEN get_device_resource_calculated(drh_45.device_id, rm_9.attributes, drh_45.value, drh_45.updated) ELSE ((drh_45.value)::text)::numeric END * COALESCE(((rm_9.attributes ->> 'scale'::text))::numeric, '1'::numeric)) END, drh_45.updated
273. 0.000 0.000 ↓ 0.0 0

Sort (cost=47.78..47.79 rows=1 width=209) (never executed)

  • Output: drh_45.updated, drh_45.calculated, drh_45.calculated_value, rm_9.attributes, drh_45.device_id, drh_45.value
  • Sort Key: drh_45.updated
274. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..47.77 rows=1 width=209) (never executed)

  • Output: drh_45.updated, drh_45.calculated, drh_45.calculated_value, rm_9.attributes, drh_45.device_id, drh_45.value
  • Join Filter: (d_10.device_type_id = dt_9.id)
275. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.29..44.60 rows=1 width=213) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, rm_9.attributes, d_10.device_type_id
276. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..36.29 rows=1 width=209) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, rm_9.attributes
  • Join Filter: (rg_9.resource_group_meta_id = rgm_9.id)
277. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..34.59 rows=1 width=213) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, rm_9.attributes, rg_9.resource_group_meta_id
  • Join Filter: (r_9.resource_group_id = rg_9.id)
278. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=7.00..32.94 rows=1 width=213) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, r_9.resource_group_id, rm_9.attributes
279. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=6.86..27.69 rows=1 width=59) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, r_9.resource_meta_id, r_9.resource_group_id
  • Hash Cond: (drh_45.resource_id = r_9.id)
280. 0.000 0.000 ↓ 0.0 0

Append (cost=0.00..20.80 rows=5 width=55) (never executed)

281. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_resource_history drh_45 (cost=0.00..0.00 rows=1 width=88) (never executed)

  • Output: drh_45.calculated, drh_45.calculated_value, drh_45.device_id, drh_45.value, drh_45.updated, drh_45.resource_id
  • Filter: ((drh_45.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_45.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_45.updated >= customer_device_history.assigned) AND (drh_45.updated <= customer_device_history.unassigned) AND (drh_45.device_id = customer_device_history.device_id))
282. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_160_chunk drh_46 (cost=0.00..1.18 rows=1 width=46) (never executed)

  • Output: drh_46.calculated, drh_46.calculated_value, drh_46.device_id, drh_46.value, drh_46.updated, drh_46.resource_id
  • Filter: ((drh_46.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_46.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_46.updated >= customer_device_history.assigned) AND (drh_46.updated <= customer_device_history.unassigned) AND (drh_46.device_id = customer_device_history.device_id))
283. 0.000 0.000 ↓ 0.0 0

Seq Scan on _timescaledb_internal._hyper_6_161_chunk drh_47 (cost=0.00..3.19 rows=1 width=46) (never executed)

  • Output: drh_47.calculated, drh_47.calculated_value, drh_47.device_id, drh_47.value, drh_47.updated, drh_47.resource_id
  • Filter: ((drh_47.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_47.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_47.updated >= customer_device_history.assigned) AND (drh_47.updated <= customer_device_history.unassigned) AND (drh_47.device_id = customer_device_history.device_id))
284. 0.000 0.000 ↓ 0.0 0

Bitmap Heap Scan on _timescaledb_internal._hyper_6_162_chunk drh_48 (cost=4.18..7.98 rows=1 width=49) (never executed)

  • Output: drh_48.calculated, drh_48.calculated_value, drh_48.device_id, drh_48.value, drh_48.updated, drh_48.resource_id
  • Recheck Cond: ((drh_48.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_48.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_48.updated >= customer_device_history.assigned) AND (drh_48.updated <= customer_device_history.unassigned))
  • Filter: (drh_48.device_id = customer_device_history.device_id)
285. 0.000 0.000 ↓ 0.0 0

Bitmap Index Scan on _hyper_6_162_chunk_device_resource_history_updated_idx (cost=0.00..4.18 rows=2 width=0) (never executed)

  • Index Cond: ((drh_48.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_48.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_48.updated >= customer_device_history.assigned) AND (drh_48.updated <= customer_device_history.unassigned))
286. 0.000 0.000 ↓ 0.0 0

Index Scan using _hyper_6_163_chunk_device_resource_history_updated_device_id_id on _timescaledb_internal._hyper_6_163_chunk drh_49 (cost=0.42..8.45 rows=1 width=48) (never executed)

  • Output: drh_49.calculated, drh_49.calculated_value, drh_49.device_id, drh_49.value, drh_49.updated, drh_49.resource_id
  • Index Cond: ((drh_49.device_id = customer_device_history.device_id) AND (drh_49.updated >= '2020-04-12 14:00:00+00'::timestamp with time zone) AND (drh_49.updated <= '2020-05-13 14:00:00+00'::timestamp with time zone) AND (drh_49.updated >= customer_device_history.assigned) AND (drh_49.updated <= customer_device_history.unassigned))
287. 0.000 0.000 ↓ 0.0 0

Hash (cost=6.63..6.63 rows=18 width=16) (never executed)

  • Output: r_9.id, r_9.resource_meta_id, r_9.resource_group_id, u0_9.primary_resource_id
288. 0.000 0.000 ↓ 0.0 0

Hash Join (cost=3.06..6.63 rows=18 width=16) (never executed)

  • Output: r_9.id, r_9.resource_meta_id, r_9.resource_group_id, u0_9.primary_resource_id
  • Hash Cond: (r_9.id = u0_9.primary_resource_id)
289. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource r_9 (cost=0.00..3.04 rows=104 width=12) (never executed)

  • Output: r_9.id, r_9.resource_meta_id, r_9.resource_group_id, r_9.measurement, r_9.field_name, r_9.created, r_9.updated, r_9.deleted
290. 0.000 0.000 ↓ 0.0 0

Hash (cost=2.83..2.83 rows=18 width=4) (never executed)

  • Output: u0_9.primary_resource_id
291. 0.000 0.000 ↓ 0.0 0

HashAggregate (cost=2.65..2.83 rows=18 width=4) (never executed)

  • Output: u0_9.primary_resource_id
  • Group Key: u0_9.primary_resource_id
292. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type u0_9 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: u0_9.primary_resource_id
293. 0.000 0.000 ↓ 0.0 0

Index Scan using resource_meta_pkey on public.resource_meta rm_9 (cost=0.14..5.24 rows=1 width=162) (never executed)

  • Output: rm_9.id, rm_9.resource_group_meta_id, rm_9.code, rm_9.description, rm_9.value_type, rm_9.unit_of_measure, rm_9.attributes, rm_9.created, rm_9.updated, rm_9.deleted
  • Index Cond: (rm_9.id = r_9.resource_meta_id)
294. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group rg_9 (cost=0.00..1.29 rows=29 width=8) (never executed)

  • Output: rg_9.id, rg_9.resource_group_meta_id, rg_9.code, rg_9.description, rg_9.created, rg_9.updated, rg_9.deleted
295. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.resource_group_meta rgm_9 (cost=0.00..1.31 rows=31 width=4) (never executed)

  • Output: rgm_9.id, rgm_9.code, rgm_9.description, rgm_9.created, rgm_9.updated, rgm_9.deleted
296. 0.000 0.000 ↓ 0.0 0

Index Scan using device_pkey on public.device d_10 (cost=0.29..8.30 rows=1 width=8) (never executed)

  • Output: d_10.id, d_10.active, d_10.eid, d_10.entity_id, d_10.address_id, d_10.device_type_id, d_10.device_group_id, d_10.parent_id, d_10.communication_status_id, d_10.last_seen, d_10.created, d_10.updated, d_10.deleted, d_10.update_user_id, d_10.installed, d_10.application_profile_id, d_10.serial, d_10.first_seen, d_10.radio_id
  • Index Cond: (d_10.id = customer_device_history.device_id)
297. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.device_type dt_9 (cost=0.00..2.52 rows=52 width=4) (never executed)

  • Output: dt_9.id, dt_9.name, dt_9.description, dt_9.created, dt_9.updated, dt_9.deleted, dt_9.update_user_id, dt_9.code, dt_9.primary_resource_id, dt_9.device_category_id, dt_9.active, dt_9.market, dt_9.default_application_profile_id, dt_9.status_policy, dt_9.has_meterage
Planning time : 127.748 ms
Execution time : 1,067.352 ms