explain.depesz.com

PostgreSQL's explain analyze made readable

Result: KLew

Settings
# exclusive inclusive rows x rows loops node
1. 0.021 1.907 ↑ 3.4 23 1

Merge Left Join (cost=3,311.74..3,312.95 rows=79 width=652) (actual time=1.858..1.907 rows=23 loops=1)

  • Output: crh.hora, crh.occurrence_type, tch.tmi, tch.tma, tch.tmf, ch.total_tratado, ch.total_10min_tratado, crh.total, crh.total_10min
  • Merge Cond: ((crh.hora = tch.hora) AND ((crh.occurrence_type)::text = (tch.occurrence_type)::text))
  • Buffers: shared hit=1,389
2.          

CTE tempo_criados_na_hora

3. 0.001 0.052 ↓ 0.0 0 1

GroupAggregate (cost=98.96..99.10 rows=1 width=133) (actual time=0.052..0.052 rows=0 loops=1)

  • Output: (date_trunc('hour'::text, oc.created_date)), oc.occurrence_type, to_char(avg((smt.created_date - oc.created_date)), 'hh24:mi:ss'::text), to_char(avg((smt_1.created_date - smt.created_date)), 'hh24:mi:ss'::text), to_char(avg((smt_2.created_date - smt_1.created_date)), 'hh24:mi:ss'::text)
  • Group Key: (date_trunc('hour'::text, oc.created_date)), oc.occurrence_type
  • Buffers: shared hit=47
4. 0.009 0.051 ↓ 0.0 0 1

Sort (cost=98.96..98.96 rows=1 width=69) (actual time=0.051..0.051 rows=0 loops=1)

  • Output: (date_trunc('hour'::text, oc.created_date)), oc.occurrence_type, smt.created_date, oc.created_date, smt_1.created_date, smt_2.created_date
  • Sort Key: (date_trunc('hour'::text, oc.created_date)) DESC, oc.occurrence_type
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=47
5. 0.001 0.042 ↓ 0.0 0 1

Nested Loop Left Join (cost=3.14..98.95 rows=1 width=69) (actual time=0.042..0.042 rows=0 loops=1)

  • Output: date_trunc('hour'::text, oc.created_date), oc.occurrence_type, smt.created_date, oc.created_date, smt_1.created_date, smt_2.created_date
  • Buffers: shared hit=47
6. 0.001 0.041 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.28..73.40 rows=1 width=85) (actual time=0.041..0.041 rows=0 loops=1)

  • Output: oc.created_date, oc.occurrence_type, oc.uuid, oc.user_uuid, smt.created_date, smt_2.created_date
  • Buffers: shared hit=47
7. 0.001 0.040 ↓ 0.0 0 1

Nested Loop (cost=1.42..47.86 rows=1 width=77) (actual time=0.040..0.040 rows=0 loops=1)

  • Output: oc.created_date, oc.occurrence_type, oc.uuid, oc.user_uuid, smt.created_date
  • Buffers: shared hit=47
8. 0.001 0.039 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.28..45.52 rows=1 width=77) (actual time=0.039..0.039 rows=0 loops=1)

  • Output: oc.created_date, oc.occurrence_type, oc.uuid, oc.user_uuid, smt.created_date
  • Buffers: shared hit=47
9. 0.006 0.038 ↓ 0.0 0 1

Nested Loop (cost=0.43..19.98 rows=1 width=69) (actual time=0.038..0.038 rows=0 loops=1)

  • Output: oc.created_date, oc.occurrence_type, oc.uuid, oc.user_uuid
  • Buffers: shared hit=47
10. 0.004 0.004 ↑ 1.0 4 1

Seq Scan on public.users us (cost=0.00..1.40 rows=4 width=16) (actual time=0.002..0.004 rows=4 loops=1)

  • Output: us.uuid, us.name, us.role, us.email, us.application, us.tenant
  • Buffers: shared hit=1
11. 0.028 0.028 ↓ 0.0 0 4

Index Scan using idx_occurrence_user_uuuid_state on public.occurrence oc (cost=0.43..4.54 rows=1 width=69) (actual time=0.007..0.007 rows=0 loops=4)

  • Output: oc.uuid, oc.version, oc.created_date, oc.last_updated_date, oc.occurrence_state, oc.entity_id, oc.entity_type, oc.occurrence_type, oc.region_uuid, oc.description_metadata, oc.user_uuid, oc.classification_uuid, oc.tenant, oc.is_test, oc.user_data, oc.is_allocable
  • Index Cond: ((oc.user_uuid = us.uuid) AND (oc.user_uuid IS NOT NULL))
  • Filter: ((NOT oc.is_test) AND (oc.created_date >= '2020-04-17 00:00:00-03'::timestamp with time zone) AND ((oc.occurrence_type)::text <> ALL ('{ORDER_RECEIVED_BY_CUSTOMER_MESSAGE_TIMEOUT,ORDER_STATE_TIMEOUT_AVAILABLE}'::text[])) AND ((oc.entity_type)::text = 'ORDER'::text))
  • Rows Removed by Filter: 10
  • Buffers: shared hit=46
12. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=40) (never executed)

  • Output: us_1.uuid, smt.created_date, smt.entity_id
  • Inner Unique: true
  • Join Filter: (us_1.uuid = o.user_uuid)
13. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=40) (never executed)

  • Output: us_1.uuid, smt.created_date, smt.entity_id
  • Join Filter: (oc.user_uuid = us_1.uuid)
14. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt (cost=0.43..20.15 rows=1 width=24) (never executed)

  • Output: smt.uuid, smt.created_date, smt.entity_id, smt.entity_type, smt.state_machine_id, smt.previous_state, smt.current_state, smt.event_id, smt.previous_state_duration_seconds
  • Index Cond: (oc.uuid = smt.entity_id)
  • Filter: (smt.created_date = (SubPlan 1))
15.          

SubPlan (for Index Scan)

16. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: min(smt2.created_date)
17. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2.uuid, smt2.created_date, smt2.entity_id, smt2.entity_type, smt2.state_machine_id, smt2.previous_state, smt2.current_state, smt2.event_id, smt2.previous_state_duration_seconds
  • Index Cond: (smt2.entity_id = smt.entity_id)
  • Filter: ((smt2.current_state)::text = 'ALLOCATED'::text)
18. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_1 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_1.uuid, us_1.name, us_1.role, us_1.email, us_1.application, us_1.tenant
19. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o.uuid, o.version, o.created_date, o.last_updated_date, o.occurrence_state, o.entity_id, o.entity_type, o.occurrence_type, o.region_uuid, o.description_metadata, o.user_uuid, o.classification_uuid, o.tenant, o.is_test, o.user_data, o.is_allocable
  • Index Cond: (o.uuid = smt.entity_id)
20. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_treatment_field_value_occurrence on public.treatment_field_value tfv (cost=0.14..2.25 rows=1 width=16) (never executed)

  • Output: tfv.occurrence_uuid
  • Index Cond: (tfv.occurrence_uuid = oc.uuid)
  • Heap Fetches: 0
21. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=40) (never executed)

  • Output: us_3.uuid, smt_2.created_date, smt_2.entity_id
  • Inner Unique: true
  • Join Filter: (us_3.uuid = o_2.user_uuid)
22. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=40) (never executed)

  • Output: us_3.uuid, smt_2.created_date, smt_2.entity_id
  • Join Filter: (oc.user_uuid = us_3.uuid)
23. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt_2 (cost=0.43..20.15 rows=1 width=24) (never executed)

  • Output: smt_2.uuid, smt_2.created_date, smt_2.entity_id, smt_2.entity_type, smt_2.state_machine_id, smt_2.previous_state, smt_2.current_state, smt_2.event_id, smt_2.previous_state_duration_seconds
  • Index Cond: (oc.uuid = smt_2.entity_id)
  • Filter: (smt_2.created_date = (SubPlan 3))
24.          

SubPlan (for Index Scan)

25. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: max(smt2_2.created_date)
26. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2_2 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2_2.uuid, smt2_2.created_date, smt2_2.entity_id, smt2_2.entity_type, smt2_2.state_machine_id, smt2_2.previous_state, smt2_2.current_state, smt2_2.event_id, smt2_2.previous_state_duration_seconds
  • Index Cond: (smt2_2.entity_id = smt_2.entity_id)
  • Filter: ((smt2_2.current_state)::text = 'CONCLUDED'::text)
27. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_3 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_3.uuid, us_3.name, us_3.role, us_3.email, us_3.application, us_3.tenant
28. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o_2 (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o_2.uuid, o_2.version, o_2.created_date, o_2.last_updated_date, o_2.occurrence_state, o_2.entity_id, o_2.entity_type, o_2.occurrence_type, o_2.region_uuid, o_2.description_metadata, o_2.user_uuid, o_2.classification_uuid, o_2.tenant, o_2.is_test, o_2.user_data, o_2.is_allocable
  • Index Cond: (o_2.uuid = smt_2.entity_id)
29. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=40) (never executed)

  • Output: us_2.uuid, smt_1.created_date, smt_1.entity_id
  • Inner Unique: true
  • Join Filter: (us_2.uuid = o_1.user_uuid)
30. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=40) (never executed)

  • Output: us_2.uuid, smt_1.created_date, smt_1.entity_id
  • Join Filter: (oc.user_uuid = us_2.uuid)
31. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt_1 (cost=0.43..20.15 rows=1 width=24) (never executed)

  • Output: smt_1.uuid, smt_1.created_date, smt_1.entity_id, smt_1.entity_type, smt_1.state_machine_id, smt_1.previous_state, smt_1.current_state, smt_1.event_id, smt_1.previous_state_duration_seconds
  • Index Cond: (smt_1.entity_id = oc.uuid)
  • Filter: (smt_1.created_date = (SubPlan 2))
32.          

SubPlan (for Index Scan)

33. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: max(smt2_1.created_date)
34. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2_1 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2_1.uuid, smt2_1.created_date, smt2_1.entity_id, smt2_1.entity_type, smt2_1.state_machine_id, smt2_1.previous_state, smt2_1.current_state, smt2_1.event_id, smt2_1.previous_state_duration_seconds
  • Index Cond: (smt2_1.entity_id = smt_1.entity_id)
  • Filter: ((smt2_1.current_state)::text = ANY ('{TREATED,CONCLUDING}'::text[]))
35. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_2 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_2.uuid, us_2.name, us_2.role, us_2.email, us_2.application, us_2.tenant
36. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o_1 (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o_1.uuid, o_1.version, o_1.created_date, o_1.last_updated_date, o_1.occurrence_state, o_1.entity_id, o_1.entity_type, o_1.occurrence_type, o_1.region_uuid, o_1.description_metadata, o_1.user_uuid, o_1.classification_uuid, o_1.tenant, o_1.is_test, o_1.user_data, o_1.is_allocable
  • Index Cond: (o_1.uuid = smt_1.entity_id)
37.          

CTE concluidos_na_hora

38. 0.001 0.088 ↓ 0.0 0 1

GroupAggregate (cost=98.96..99.08 rows=1 width=53) (actual time=0.088..0.088 rows=0 loops=1)

  • Output: (date_trunc('hour'::text, oc_1.last_updated_date)), oc_1.occurrence_type, count(*) FILTER (WHERE ((oc_1.occurrence_state)::text = 'CONCLUDED'::text)), count(*) FILTER (WHERE (((oc_1.occurrence_state)::text = 'CONCLUDED'::text) AND ((oc_1.last_updated_date - oc_1.created_date) > '00:10:00'::interval)))
  • Group Key: (date_trunc('hour'::text, oc_1.last_updated_date)), oc_1.occurrence_type
  • Buffers: shared hit=47
39. 0.006 0.087 ↓ 0.0 0 1

Sort (cost=98.96..98.96 rows=1 width=63) (actual time=0.087..0.087 rows=0 loops=1)

  • Output: (date_trunc('hour'::text, oc_1.last_updated_date)), oc_1.occurrence_type, oc_1.occurrence_state, oc_1.last_updated_date, oc_1.created_date
  • Sort Key: (date_trunc('hour'::text, oc_1.last_updated_date)) DESC, oc_1.occurrence_type
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=47
40. 0.001 0.081 ↓ 0.0 0 1

Nested Loop Left Join (cost=3.14..98.95 rows=1 width=63) (actual time=0.081..0.081 rows=0 loops=1)

  • Output: date_trunc('hour'::text, oc_1.last_updated_date), oc_1.occurrence_type, oc_1.occurrence_state, oc_1.last_updated_date, oc_1.created_date
  • Buffers: shared hit=47
41. 0.001 0.080 ↓ 0.0 0 1

Nested Loop Left Join (cost=2.28..73.40 rows=1 width=87) (actual time=0.079..0.080 rows=0 loops=1)

  • Output: oc_1.last_updated_date, oc_1.occurrence_type, oc_1.occurrence_state, oc_1.created_date, oc_1.uuid, oc_1.user_uuid
  • Buffers: shared hit=47
42. 0.001 0.079 ↓ 0.0 0 1

Nested Loop (cost=1.42..47.86 rows=1 width=87) (actual time=0.078..0.079 rows=0 loops=1)

  • Output: oc_1.last_updated_date, oc_1.occurrence_type, oc_1.occurrence_state, oc_1.created_date, oc_1.uuid, oc_1.user_uuid
  • Buffers: shared hit=47
43. 0.001 0.078 ↓ 0.0 0 1

Nested Loop Left Join (cost=1.28..45.52 rows=1 width=87) (actual time=0.078..0.078 rows=0 loops=1)

  • Output: oc_1.last_updated_date, oc_1.occurrence_type, oc_1.occurrence_state, oc_1.created_date, oc_1.uuid, oc_1.user_uuid
  • Buffers: shared hit=47
44. 0.006 0.077 ↓ 0.0 0 1

Nested Loop (cost=0.43..19.98 rows=1 width=87) (actual time=0.077..0.077 rows=0 loops=1)

  • Output: oc_1.last_updated_date, oc_1.occurrence_type, oc_1.occurrence_state, oc_1.created_date, oc_1.uuid, oc_1.user_uuid
  • Buffers: shared hit=47
45. 0.007 0.007 ↑ 1.0 4 1

Seq Scan on public.users us_4 (cost=0.00..1.40 rows=4 width=16) (actual time=0.005..0.007 rows=4 loops=1)

  • Output: us_4.uuid, us_4.name, us_4.role, us_4.email, us_4.application, us_4.tenant
  • Buffers: shared hit=1
46. 0.064 0.064 ↓ 0.0 0 4

Index Scan using idx_occurrence_user_uuuid_state on public.occurrence oc_1 (cost=0.43..4.54 rows=1 width=87) (actual time=0.016..0.016 rows=0 loops=4)

  • Output: oc_1.uuid, oc_1.version, oc_1.created_date, oc_1.last_updated_date, oc_1.occurrence_state, oc_1.entity_id, oc_1.entity_type, oc_1.occurrence_type, oc_1.region_uuid, oc_1.description_metadata, oc_1.user_uuid, oc_1.classification_uuid, oc_1.tenant, oc_1.is_test, oc_1.user_data, oc_1.is_allocable
  • Index Cond: ((oc_1.user_uuid = us_4.uuid) AND (oc_1.user_uuid IS NOT NULL))
  • Filter: ((NOT oc_1.is_test) AND (oc_1.created_date >= '2020-04-17 00:00:00-03'::timestamp with time zone) AND ((oc_1.occurrence_type)::text <> ALL ('{ORDER_RECEIVED_BY_CUSTOMER_MESSAGE_TIMEOUT,ORDER_STATE_TIMEOUT_AVAILABLE}'::text[])) AND ((oc_1.entity_type)::text = 'ORDER'::text))
  • Rows Removed by Filter: 10
  • Buffers: shared hit=46
47. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=32) (never executed)

  • Output: us_5.uuid, smt_3.entity_id
  • Inner Unique: true
  • Join Filter: (us_5.uuid = o_3.user_uuid)
48. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=32) (never executed)

  • Output: us_5.uuid, smt_3.entity_id
  • Join Filter: (oc_1.user_uuid = us_5.uuid)
49. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt_3 (cost=0.43..20.15 rows=1 width=16) (never executed)

  • Output: smt_3.uuid, smt_3.created_date, smt_3.entity_id, smt_3.entity_type, smt_3.state_machine_id, smt_3.previous_state, smt_3.current_state, smt_3.event_id, smt_3.previous_state_duration_seconds
  • Index Cond: (oc_1.uuid = smt_3.entity_id)
  • Filter: (smt_3.created_date = (SubPlan 5))
50.          

SubPlan (for Index Scan)

51. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: min(smt2_3.created_date)
52. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2_3 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2_3.uuid, smt2_3.created_date, smt2_3.entity_id, smt2_3.entity_type, smt2_3.state_machine_id, smt2_3.previous_state, smt2_3.current_state, smt2_3.event_id, smt2_3.previous_state_duration_seconds
  • Index Cond: (smt2_3.entity_id = smt_3.entity_id)
  • Filter: ((smt2_3.current_state)::text = 'ALLOCATED'::text)
53. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_5 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_5.uuid, us_5.name, us_5.role, us_5.email, us_5.application, us_5.tenant
54. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o_3 (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o_3.uuid, o_3.version, o_3.created_date, o_3.last_updated_date, o_3.occurrence_state, o_3.entity_id, o_3.entity_type, o_3.occurrence_type, o_3.region_uuid, o_3.description_metadata, o_3.user_uuid, o_3.classification_uuid, o_3.tenant, o_3.is_test, o_3.user_data, o_3.is_allocable
  • Index Cond: (o_3.uuid = smt_3.entity_id)
55. 0.000 0.000 ↓ 0.0 0

Index Only Scan using idx_treatment_field_value_occurrence on public.treatment_field_value tfv_1 (cost=0.14..2.25 rows=1 width=16) (never executed)

  • Output: tfv_1.occurrence_uuid
  • Index Cond: (tfv_1.occurrence_uuid = oc_1.uuid)
  • Heap Fetches: 0
56. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=32) (never executed)

  • Output: us_7.uuid, smt_5.entity_id
  • Inner Unique: true
  • Join Filter: (us_7.uuid = o_5.user_uuid)
57. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=32) (never executed)

  • Output: us_7.uuid, smt_5.entity_id
  • Join Filter: (oc_1.user_uuid = us_7.uuid)
58. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt_5 (cost=0.43..20.15 rows=1 width=16) (never executed)

  • Output: smt_5.uuid, smt_5.created_date, smt_5.entity_id, smt_5.entity_type, smt_5.state_machine_id, smt_5.previous_state, smt_5.current_state, smt_5.event_id, smt_5.previous_state_duration_seconds
  • Index Cond: (oc_1.uuid = smt_5.entity_id)
  • Filter: (smt_5.created_date = (SubPlan 7))
59.          

SubPlan (for Index Scan)

60. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: max(smt2_5.created_date)
61. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2_5 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2_5.uuid, smt2_5.created_date, smt2_5.entity_id, smt2_5.entity_type, smt2_5.state_machine_id, smt2_5.previous_state, smt2_5.current_state, smt2_5.event_id, smt2_5.previous_state_duration_seconds
  • Index Cond: (smt2_5.entity_id = smt_5.entity_id)
  • Filter: ((smt2_5.current_state)::text = 'CONCLUDED'::text)
62. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_7 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_7.uuid, us_7.name, us_7.role, us_7.email, us_7.application, us_7.tenant
63. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o_5 (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o_5.uuid, o_5.version, o_5.created_date, o_5.last_updated_date, o_5.occurrence_state, o_5.entity_id, o_5.entity_type, o_5.occurrence_type, o_5.region_uuid, o_5.description_metadata, o_5.user_uuid, o_5.classification_uuid, o_5.tenant, o_5.is_test, o_5.user_data, o_5.is_allocable
  • Index Cond: (o_5.uuid = smt_5.entity_id)
64. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.86..25.44 rows=1 width=32) (never executed)

  • Output: us_6.uuid, smt_4.entity_id
  • Inner Unique: true
  • Join Filter: (us_6.uuid = o_4.user_uuid)
65. 0.000 0.000 ↓ 0.0 0

Nested Loop (cost=0.43..21.96 rows=1 width=32) (never executed)

  • Output: us_6.uuid, smt_4.entity_id
  • Join Filter: (oc_1.user_uuid = us_6.uuid)
66. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt_4 (cost=0.43..20.15 rows=1 width=16) (never executed)

  • Output: smt_4.uuid, smt_4.created_date, smt_4.entity_id, smt_4.entity_type, smt_4.state_machine_id, smt_4.previous_state, smt_4.current_state, smt_4.event_id, smt_4.previous_state_duration_seconds
  • Index Cond: (smt_4.entity_id = oc_1.uuid)
  • Filter: (smt_4.created_date = (SubPlan 6))
67.          

SubPlan (for Index Scan)

68. 0.000 0.000 ↓ 0.0 0

Aggregate (cost=6.65..6.75 rows=1 width=8) (never executed)

  • Output: max(smt2_4.created_date)
69. 0.000 0.000 ↓ 0.0 0

Index Scan using idx_state_machine_trail_entity_id_type on public.state_machine_trail smt2_4 (cost=0.43..6.65 rows=1 width=8) (never executed)

  • Output: smt2_4.uuid, smt2_4.created_date, smt2_4.entity_id, smt2_4.entity_type, smt2_4.state_machine_id, smt2_4.previous_state, smt2_4.current_state, smt2_4.event_id, smt2_4.previous_state_duration_seconds
  • Index Cond: (smt2_4.entity_id = smt_4.entity_id)
  • Filter: ((smt2_4.current_state)::text = ANY ('{TREATED,CONCLUDING}'::text[]))
70. 0.000 0.000 ↓ 0.0 0

Seq Scan on public.users us_6 (cost=0.00..1.40 rows=4 width=16) (never executed)

  • Output: us_6.uuid, us_6.name, us_6.role, us_6.email, us_6.application, us_6.tenant
71. 0.000 0.000 ↓ 0.0 0

Index Scan using pk_occurrence on public.occurrence o_4 (cost=0.43..3.37 rows=1 width=32) (never executed)

  • Output: o_4.uuid, o_4.version, o_4.created_date, o_4.last_updated_date, o_4.occurrence_state, o_4.entity_id, o_4.entity_type, o_4.occurrence_type, o_4.region_uuid, o_4.description_metadata, o_4.user_uuid, o_4.classification_uuid, o_4.tenant, o_4.is_test, o_4.user_data, o_4.is_allocable
  • Index Cond: (o_4.uuid = smt_4.entity_id)
72.          

CTE criados_na_hora

73. 0.041 1.635 ↑ 3.4 23 1

GroupAggregate (cost=3,084.97..3,094.85 rows=79 width=53) (actual time=1.594..1.635 rows=23 loops=1)

  • Output: (date_trunc('hour'::text, oc_2.created_date)), oc_2.occurrence_type, count(*) FILTER (WHERE ((oc_2.occurrence_state)::text = 'CONCLUDED'::text)), count(*) FILTER (WHERE (((oc_2.occurrence_state)::text = 'CONCLUDED'::text) AND ((oc_2.last_updated_date - oc_2.created_date) > '00:10:00'::interval)))
  • Group Key: (date_trunc('hour'::text, oc_2.created_date)), oc_2.occurrence_type
  • Buffers: shared hit=1,295
74. 0.050 1.594 ↑ 3.0 26 1

Sort (cost=3,084.97..3,085.17 rows=79 width=63) (actual time=1.583..1.594 rows=26 loops=1)

  • Output: (date_trunc('hour'::text, oc_2.created_date)), oc_2.occurrence_type, oc_2.occurrence_state, oc_2.last_updated_date, oc_2.created_date
  • Sort Key: (date_trunc('hour'::text, oc_2.created_date)) DESC, oc_2.occurrence_type
  • Sort Method: quicksort Memory: 28kB
  • Buffers: shared hit=1,295
75. 1.544 1.544 ↑ 3.0 26 1

Index Scan using idx_occurrence_created_date on public.occurrence oc_2 (cost=0.29..3,082.48 rows=79 width=63) (actual time=0.256..1.544 rows=26 loops=1)

  • Output: date_trunc('hour'::text, oc_2.created_date), oc_2.occurrence_type, oc_2.occurrence_state, oc_2.last_updated_date, oc_2.created_date
  • Index Cond: (oc_2.created_date >= '2020-04-17 00:00:00-03'::timestamp with time zone)
  • Filter: (((oc_2.occurrence_type)::text <> ALL ('{ORDER_RECEIVED_BY_CUSTOMER_MESSAGE_TIMEOUT,ORDER_STATE_TIMEOUT_AVAILABLE}'::text[])) AND ((oc_2.entity_type)::text = 'ORDER'::text))
  • Rows Removed by Filter: 1,337
  • Buffers: shared hit=1,295
76. 0.022 1.824 ↑ 3.4 23 1

Merge Left Join (cost=18.50..19.20 rows=79 width=556) (actual time=1.794..1.824 rows=23 loops=1)

  • Output: crh.hora, crh.occurrence_type, crh.total, crh.total_10min, ch.total_tratado, ch.total_10min_tratado
  • Merge Cond: ((crh.hora = ch.hora) AND ((crh.occurrence_type)::text = (ch.occurrence_type)::text))
  • Buffers: shared hit=1,342
77. 0.039 1.702 ↑ 3.4 23 1

Sort (cost=18.29..18.49 rows=79 width=540) (actual time=1.692..1.702 rows=23 loops=1)

  • Output: crh.hora, crh.occurrence_type, crh.total, crh.total_10min
  • Sort Key: crh.hora DESC, crh.occurrence_type
  • Sort Method: quicksort Memory: 28kB
  • Buffers: shared hit=1,295
78. 1.663 1.663 ↑ 3.4 23 1

CTE Scan on criados_na_hora crh (cost=0.00..15.80 rows=79 width=540) (actual time=1.597..1.663 rows=23 loops=1)

  • Output: crh.hora, crh.occurrence_type, crh.total, crh.total_10min
  • Buffers: shared hit=1,295
79. 0.011 0.100 ↓ 0.0 0 1

Sort (cost=0.21..0.22 rows=1 width=540) (actual time=0.099..0.100 rows=0 loops=1)

  • Output: ch.total_tratado, ch.total_10min_tratado, ch.hora, ch.occurrence_type
  • Sort Key: ch.hora DESC, ch.occurrence_type
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=47
80. 0.089 0.089 ↓ 0.0 0 1

CTE Scan on concluidos_na_hora ch (cost=0.00..0.20 rows=1 width=540) (actual time=0.089..0.089 rows=0 loops=1)

  • Output: ch.total_tratado, ch.total_10min_tratado, ch.hora, ch.occurrence_type
  • Buffers: shared hit=47
81. 0.008 0.062 ↓ 0.0 0 1

Sort (cost=0.21..0.22 rows=1 width=620) (actual time=0.062..0.062 rows=0 loops=1)

  • Output: tch.tmi, tch.tma, tch.tmf, tch.hora, tch.occurrence_type
  • Sort Key: tch.hora DESC, tch.occurrence_type
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=47
82. 0.054 0.054 ↓ 0.0 0 1

CTE Scan on tempo_criados_na_hora tch (cost=0.00..0.20 rows=1 width=620) (actual time=0.053..0.054 rows=0 loops=1)

  • Output: tch.tmi, tch.tma, tch.tmf, tch.hora, tch.occurrence_type
  • Buffers: shared hit=47
Planning time : 6.572 ms
Execution time : 2.565 ms