explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 2lRV

Settings
# exclusive inclusive rows x rows loops node
1. 0.004 32,933.112 ↑ 1.0 10 1

Limit (cost=0.43..1,663.32 rows=10 width=1,643) (actual time=32,905.781..32,933.112 rows=10 loops=1)

2. 3,327.737 32,933.108 ↑ 745.9 10 1

Nested Loop Left Join (cost=0.43..1,240,348.45 rows=7,459 width=1,643) (actual time=32,905.781..32,933.108 rows=10 loops=1)

  • Join Filter: (patients.id = patient_alt_names.patient_id)
  • Filter: (((patients.last_name)::text ~~* 'terry%'::text) OR (patient_alt_names.last_name ~~* 'terry%'::text))
  • Rows Removed by Filter: 3852330
3. 29,605.371 29,605.371 ↑ 1.1 3,852,340 1

Index Scan using patients_last_name_idx on patients (cost=0.43..1,063,745.57 rows=4,400,264 width=1,588) (actual time=0.086..29,605.371 rows=3,852,340 loops=1)

  • Filter: ((NOT has_deleted) AND (company_id = 1))
  • Rows Removed by Filter: 1
4. 0.000 0.000 ↓ 0.0 0 3,852,340

Materialize (cost=0.00..14.26 rows=2 width=40) (actual time=0.000..0.000 rows=0 loops=3,852,340)

5. 0.003 0.003 ↓ 0.0 0 1

Seq Scan on patient_alt_names (cost=0.00..14.25 rows=2 width=40) (actual time=0.003..0.003 rows=0 loops=1)

  • Filter: (name_type = 'alias'::text)