带解密的多个 Where 子句 [英] Multiple Where clause with decryption

查看:73
本文介绍了带解密的多个 Where 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像这样的查询是基本解密每个 where 条件的用户名还是只解密一次并将其应用于每个条件?

Would a query like this basically decrypt the usernames for each where condition or just once and apply that to each condition?

SELECT * 
FROM TableA 
WHERE (
    CONCAT_WS(
        ' ', 
        AES_DECRYPT(TableA.FirstName, "fnkey"), 
        AES_DECRYPT(TableA.LastName, "lnkey")
    ) LIKE '%RAY%' 
    OR 
    CONCAT_WS(
        ' ', 
        AES_DECRYPT(TableA.LastName, "lnkey"), 
        AES_DECRYPT(TableA.FirstName, "fnkey")
    ) LIKE '%RAY%'
);

推荐答案

我不知道该函数是为每一行计算一次还是更多.这取决于查询优化器.你可以通过基准来建立它.

I cannot tell if the function is evaluated once for each row or more. It depends on the query optimizer. You could establish it by benchmark.

无论如何,这个查询是非常低效的.它将执行全表扫描并为每一行计算此函数.您不能在此处使用索引.您不会在具有多于几行的表上实现此查询.

Anyway, this query is very inefficient. It will do a full table scan and calculate this function for each row. You cannot use an index here. You would not implement this query on a table with more than a couple of rows.

这篇关于带解密的多个 Where 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆