I have the current query below where email addresses in different tables are in various cases so I need to compare lowercase to lowercase. But running the query below with lower() is something like 100 million times slower than running it without.
Can anyone suggest a workaround?
SELECT
person_oct.email,
unsubs.unsubs_email
FROM
public.unsubs,
public.person_oct
WHERE
lower(person_oct.email) = lower(unsubs.unsubs_email) AND
unsubs.unsubs_email IS NOT NULL AND
unsubs.unsubs_email != '' AND
person_oct.email != '' AND
person_oct.email IS NOT NULL ;