update pis_p_shenhjg t set t.biaom='PIS_P_RenK' where t.biaom like 'PIS_P_Renk';
update pis_p_shenhjg t set t.biaom='PIS_P_RenK' where t.biaom='PIS_P_Renk';
麻烦大家讲解一下上面哪个执行更优一些?
还有我公司的服务器连接总是很慢,查看反正是内存占用很高,遇到这种情况可以怎么样优化一下?谢谢大家啦!
update pis_p_shenhjg t set t.biaom='PIS_P_RenK' where t.biaom='PIS_P_Renk';
麻烦大家讲解一下上面哪个执行更优一些?
还有我公司的服务器连接总是很慢,查看反正是内存占用很高,遇到这种情况可以怎么样优化一下?谢谢大家啦!
如果在biaom上建立索引,效率更高些
like 执行效率绝对的高。
update pis_p_shenhjg t set t.biaom='PIS_P_RenK' where t.biaom like 'PIS_P_Renk';
这个LIKE 会被转化为 = 的
要说的话就你第2个语句少了这个转化的步骤
How the CBO Evaluates the LIKE Operator
The optimizer simplifies conditions that use the LIKE comparison operator to
compare an expression with no wildcard characters into an equivalent condition
that uses an equality operator instead.
In the following example, the optimizer simplifies the first condition into the
second:
last_name LIKE ’SMITH’
is transformed into
last_name = ’SMITH’
The optimizer can simplify these expressions only when the comparison involves
variable-length datatypes. For example, if last_name was of type CHAR(10), then
the optimizer cannot transform the LIKE operation into an equality operation due
to the equality operator following blank-padded semantics and LIKE not following
blank-padded semantics.
什么全表扫描不全表扫描的,like很多时候照样可以用索引,况且楼主又没有说那列上有索引
回答和索引有关系的,肯定在网上或听人说的,记住:like有通配符的情况下,才和索引有一定的关系
我说了,你的问题就如问在oracle中where id = 1与where id in (1)他们之间哪个效率高一样
这个......, 如果我是oracle公司的研发人员,基本上无视这个SQL,因为它压根什么都不用更新啊
set的值跟condition的值一模一样,有必要作更新吗?有必要吗?
like不用完全匹配,所以要比=省事一些,实际测试也是这个结果,like使用的资源要少很多
=和like都需要匹配所有的行,但为什么like过滤起来比=效率高,我想只有看了内部实现才知道