Searching for: TABITH MAGDALENO (Jan. 1, 1990)
Explaining: legacy + levenshtein
Unindexed LIKE '%name%' — slow, included for comparison. 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"), TABITH, 2) AS "_fn_dist", levenshtein_less_equal(UPPER("records_courtrecord"."last_name"), MAGDALENO, 2) AS "_ln_dist" FROM "records_courtrecord" WHERE (UPPER("records_courtrecord"."first_name"::text) LIKE UPPER(%TABITH%) AND UPPER("records_courtrecord"."last_name"::text) LIKE UPPER(%MAGDALENO%) AND "records_courtrecord"."date_of_birth" = 1990-01-01 AND levenshtein_less_equal(UPPER("records_courtrecord"."first_name"), TABITH, 2) <= 2 AND levenshtein_less_equal(UPPER("records_courtrecord"."last_name"), MAGDALENO, 2) <= 2) LIMIT 200
Query plan
EXPLAIN (ANALYZE, BUFFERS)
Limit (cost=0.56..2554.09 rows=1 width=72) (actual time=1.930..3.531 rows=1.00 loops=1)
Buffers: shared hit=1496
-> Index Scan using idx_person_date_of_birth on records_courtrecord (cost=0.56..2554.09 rows=1 width=72) (actual time=1.928..3.528 rows=1.00 loops=1)
Index Cond: (date_of_birth = '1990-01-01'::date)
Filter: ((upper((first_name)::text) ~~ '%TABITH%'::text) AND (upper((last_name)::text) ~~ '%MAGDALENO%'::text) AND (levenshtein_less_equal(upper((first_name)::text), 'TABITH'::text, 2) <= 2) AND (levenshtein_less_equal(upper((last_name)::text), 'MAGDALENO'::text, 2) <= 2))
Rows Removed by Filter: 2195
Index Searches: 1
Buffers: shared hit=1496
Planning:
Buffers: shared hit=270
Planning Time: 1.814 ms
Execution Time: 3.781 ms