我有下面的当前查询,其中不同表中的电子邮件地址在各种情况下,所以我需要比较小写和小写。但是使用lower()运行下面的查询比没有运行它的速度快1亿倍。
有人可以建议解决方法吗?
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 ;
答案 0 :(得分:0)
在许多SQL服务器中,字符串比较默认情况下不区分大小写。您可能不需要lower()
来电。
您也不需要查询的最后两行,因为它们隐含在where-block的前三行中。