explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2gNp : Relatorio Geral

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 1,157.241 8,678.957 ↓ 0.0 470,524 1

WindowAgg (cost=0..0 rows=0 width=0) (actual time=821.258..8,678.957 rows=470,524 loops=1)

2. 349.585 934.380 ↓ 0.0 470,524 1

Sort (cost=0..0 rows=0 width=0) (actual time=821.144..934.380 rows=470,524 loops=1)

  • Sort Key: p.id, a.created_time
  • Sort Method: external merge Disk: 32824kB
3. 0.000 584.795 ↓ 0.0 470,524 1

Gather (cost=0..0 rows=0 width=0) (actual time=0.406..584.795 rows=470,524 loops=1)

  • Workers Planned: 2
  • Workers Launched: 2
4. 562.597 609.193 ↓ 0.0 156,841 3

Nested Loop (cost=0..0 rows=0 width=0) (actual time=0.206..609.193 rows=156,841 loops=3)

5. 15.485 46.590 ↓ 0.0 89,959 3

Hash Join (cost=0..0 rows=0 width=0) (actual time=0.173..46.590 rows=89,959 loops=3)

  • Hash Cond: (p.tenancy_id = t.id)
6. 31.065 31.065 ↓ 0.0 90,041 3

Parallel Seq Scan on patients p (cost=0..0 rows=0 width=0) (actual time=0.012..31.065 rows=90,041 loops=3)

  • Filter: (NOT is_user_test)
  • Rows Removed by Filter: 103
7. 0.005 0.040 ↓ 0.0 23 3

Hash (cost=0..0 rows=0 width=0) (actual time=0.040..0.040 rows=23 loops=3)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
8. 0.035 0.035 ↓ 0.0 23 3

Seq Scan on tenancies t (cost=0..0 rows=0 width=0) (actual time=0.010..0.035 rows=23 loops=3)

  • Filter: (subscription_id ~~ 'a-%'::text)
  • Rows Removed by Filter: 67
9. 0.006 0.006 ↓ 0.0 2 269,876

Index Scan using index_attendances_patient_id on attendances a (cost=0..0 rows=0 width=0) (actual time=0.004..0.006 rows=2 loops=269,876)

  • Index Cond: (patient_id = p.id)
10.          

SubPlan (forWindowAgg)

11. 470.524 2,352.620 ↓ 0.0 0 470,524

Limit (cost=0..0 rows=0 width=0) (actual time=0.005..0.005 rows=0 loops=470,524)

12. 0.000 1,882.096 ↓ 0.0 0 470,524

Sort (cost=0..0 rows=0 width=0) (actual time=0.004..0.004 rows=0 loops=470,524)

  • Sort Key: _pbp.created DESC
  • Sort Method: quicksort Memory: 25kB
13. 1,882.096 1,882.096 ↓ 0.0 0 470,524

Index Scan using index_procedure_blood_pressures_attendance_id on procedure_blood_pressures _pbp (cost=0..0 rows=0 width=0) (actual time=0.004..0.004 rows=0 loops=470,524)

  • Index Cond: (attendance_id = a.id)
14. 0.000 1,411.572 ↓ 0.0 0 470,524

Limit (cost=0..0 rows=0 width=0) (actual time=0.003..0.003 rows=0 loops=470,524)

15. 470.524 1,411.572 ↓ 0.0 0 470,524

Sort (cost=0..0 rows=0 width=0) (actual time=0.003..0.003 rows=0 loops=470,524)

  • Sort Key: _pbg.created DESC
  • Sort Method: quicksort Memory: 25kB
16. 941.048 941.048 ↓ 0.0 0 470,524

Index Scan using index_procedure_blood_glucoses_attendance_id on procedure_blood_glucoses _pbg (cost=0..0 rows=0 width=0) (actual time=0.002..0.002 rows=0 loops=470,524)

  • Index Cond: (attendance_id = a.id)
17. 470.524 1,882.096 ↓ 0.0 1 470,524

Aggregate (cost=0..0 rows=0 width=0) (actual time=0.004..0.004 rows=1 loops=470,524)

18. 0.000 1,411.572 ↓ 0.0 0 470,524

Nested Loop (cost=0..0 rows=0 width=0) (actual time=0.003..0.003 rows=0 loops=470,524)

19. 941.048 941.048 ↓ 0.0 1 470,524

Index Scan using index_patient_prescriptions_attendance_id on patient_prescriptions _pp (cost=0..0 rows=0 width=0) (actual time=0.002..0.002 rows=1 loops=470,524)

  • Index Cond: (attendance_id = a.id)
20. 527.234 527.234 ↓ 0.0 0 263,617

Index Scan using patient_medicines_patient_prescription_id_index on patient_medicines _pm (cost=0..0 rows=0 width=0) (actual time=0.001..0.002 rows=0 loops=263,617)

  • Index Cond: (patient_prescription_id = _pp.id)
21. 470.524 941.048 ↓ 0.0 1 470,524

Aggregate (cost=0..0 rows=0 width=0) (actual time=0.002..0.002 rows=1 loops=470,524)

22. 0.000 470.524 ↓ 0.0 0 470,524

Bitmap Heap Scan on procedure_exams _pe (cost=0..0 rows=0 width=0) (actual time=0.001..0.001 rows=0 loops=470,524)

  • Recheck Cond: (attendance_id = a.id)
  • Heap Blocks: exact=623
23. 470.524 470.524 ↓ 0.0 0 470,524

Bitmap Index Scan on index_procedure_exams_attendance_id (cost=0..0 rows=0 width=0) (actual time=0.001..0.001 rows=0 loops=470,524)

  • Index Cond: (attendance_id = a.id)
Planning time : 0.628 ms
Execution time : 8,718.730 ms