I am trying to make a similar query faster:
SELECT levenshtein(substring(keywords, 1,5),'texas') as distance
FROM stuff ORDER BY distance ASC
Unfortunately and as expected, the query takes an eternity. How can I accomplish the same thing, but make it fast? The table is 5 million rows.
Best Answer
Functions are slow and it is a complex function. Try optimizing the function.
Or select down to like .NET and do it there.
If you get a lot of exact matches you can make that separate.