Searching for: TABITHA MAGDALENO (Jan. 1, 1990)
Explaining: soundex + levenshtein
Phonetic pre-filter using SOUNDEX codes. Edit distance ≤ 2 — precision filter applied on top of other modes.
SQL
SELECT "records_courtrecord"."id", "records_courtrecord"."first_name", "records_courtrecord"."last_name", "records_courtrecord"."middle_name", "records_courtrecord"."date_of_birth", "records_courtrecord"."nicknames", "records_courtrecord"."person_id", levenshtein_less_equal(UPPER("records_courtrecord"."first_name"), TABITHA, 2) AS "_fn_dist", levenshtein_less_equal(UPPER("records_courtrecord"."last_name"), MAGDALENO, 2) AS "_ln_dist" FROM "records_courtrecord" WHERE (((SOUNDEX(first_name) = SOUNDEX(TABITHA)) AND (SOUNDEX(last_name) = SOUNDEX(MAGDALENO))) AND "records_courtrecord"."date_of_birth" = 1990-01-01 AND levenshtein_less_equal(UPPER("records_courtrecord"."first_name"), TABITHA, 2) <= 2 AND levenshtein_less_equal(UPPER("records_courtrecord"."last_name"), MAGDALENO, 2) <= 2) LIMIT 200
Query plan
EXPLAIN (ANALYZE, BUFFERS)
Limit (cost=2297.25..2309.77 rows=1 width=72) (actual time=1.752..1.754 rows=1.00 loops=1)
Buffers: shared hit=17
-> Bitmap Heap Scan on records_courtrecord (cost=2297.25..2309.77 rows=1 width=72) (actual time=1.750..1.752 rows=1.00 loops=1)
Recheck Cond: ((date_of_birth = '1990-01-01'::date) AND (soundex((first_name)::text) = 'T130'::text))
Filter: ((soundex((last_name)::text) = 'M234'::text) AND (levenshtein_less_equal(upper((first_name)::text), 'TABITHA'::text, 2) <= 2) AND (levenshtein_less_equal(upper((last_name)::text), 'MAGDALENO'::text, 2) <= 2))
Rows Removed by Filter: 1
Heap Blocks: exact=2
Buffers: shared hit=17
-> BitmapAnd (cost=2297.25..2297.25 rows=11 width=0) (actual time=1.667..1.668 rows=0.00 loops=1)
Buffers: shared hit=15
-> Bitmap Index Scan on idx_person_date_of_birth (cost=0.00..19.54 rows=2236 width=0) (actual time=0.344..0.344 rows=2196.00 loops=1)
Index Cond: (date_of_birth = '1990-01-01'::date)
Index Searches: 1
Buffers: shared hit=6
-> Bitmap Index Scan on idx_person_first_name_soundex (cost=0.00..2277.47 rows=270000 width=0) (actual time=1.161..1.161 rows=6903.00 loops=1)
Index Cond: (soundex((first_name)::text) = 'T130'::text)
Index Searches: 1
Buffers: shared hit=9
Planning:
Buffers: shared hit=274
Planning Time: 2.289 ms
Execution Time: 1.865 ms