使用like时left outer join和inner join的区别
--select top 10000 * into #s from search
set statistics time on
set statistics io on
select userId,count(*) as searchNum,s.Posttime, p.RootID ,s.url
from #s s
left outer join ProductInfo p on s.ProductID like '%' + p.RootID + '%'
group by userid, p.RootID,s.Posttime,s.url --dbo.GetPlatform(s.url) like 41s --- like 13s --去掉userid的case 13s
select userId,count(*) as searchNum,s.Posttime,p.RootID ,s.url
from #s s
inner join ProductInfo p on s.ProductID like '%' + p.RootID + '%'
group by userid, p.RootID, s.Posttime,s.url
set statistics time off
set statistics io off

SQL Server 执行时间:
CPU 时间 = 0 毫秒,占用时间 = 0 毫秒。
(1228 行受影响)
表 '#s__________________________________________________________________________________________________________________000000000655'。扫描计数 3,逻辑读取 223 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 'Worktable'。扫描计数 287,逻辑读取 19242 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 'CNKI_ProductInfo'。扫描计数 2,逻辑读取 4207 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 'Worktable'。扫描计数 0,逻辑读取 0 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
(1 行受影响)
SQL Server 执行时间:
CPU 时间 = 2984 毫秒,占用时间 = 2704 毫秒。
(1224 行受影响)
表 'CNKI_ProductInfo'。扫描计数 3,逻辑读取 16 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 'Worktable'。扫描计数 2,逻辑读取 84888 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
表 '#s__________________________________________________________________________________________________________________000000000655'。扫描计数 2,逻辑读取 446 次,物理读取 0 次,预读 0 次,lob 逻辑读取 0 次,lob 物理读取 0 次,lob 预读 0 次。
(1 行受影响)
SQL Server 执行时间:
CPU 时间 = 24923 毫秒,占用时间 = 12861 毫秒。
最好把like改成以下方式实现
select Convert(varchar(10),s.Posttime,20),p.RootID,dbo.GetPlatform(s.url),case userId when -1 then -1 else 2 end ,COUNT(*),0,0
from Search s cross apply dbo.ParameterSplit(s.ProductID,';') sp
inner join ProductInfo p on sp.Item = p.RootID
where s.PostTime >= Convert(varchar(10),'2012-01-01',20) and s.PostTime < Convert(varchar(10),'2013-09-09',20)
group by Convert(varchar(10),s.Posttime,20),p.RootID,dbo.GetPlatform(s.url),case userId when -1 then -1 else 2 end
使用like时left outer join和inner join的区别的更多相关文章
- HIVE中join、semi join、outer join
补充说明 left outer join where is not null与left semi join的联系与区别:两者均可实现exists in操作,不同的是,前者允许右表的字段在select或 ...
- SQL中inner join、outer join和cross join的区别
对于SQL中inner join.outer join和cross join的区别简介:现有两张表,Table A 是左边的表.Table B 是右边的表.其各有四条记录,其中有两条记录name是相同 ...
- SQL的inner join、left join、right join、full outer join、union、union all
主题: SQL的inner join.left join.right join.full outer join.union.union all的学习. Table A和Table B表如下所示: 表A ...
- 图解SQL的inner join、left join、right join、full outer join、union、union all的区别
SQL的Join语法有很多,inner join(等值连接) 只返回两个表中联结字段相等的行,left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录,right join(右 ...
- Linq表连接大全(INNER JOIN、LEFT OUTER JOIN、RIGHT OUTER JOIN、FULL OUTER JOIN、CROSS JOIN)
我们知道在SQL中一共有五种JOIN操作:INNER JOIN.LEFT OUTER JOIN.RIGHT OUTER JOIN.FULL OUTER JOIN.CROSS JOIN 1>先创建 ...
- 【转载】SQL中inner join、outer join和cross join的区别
对于SQL中inner join.outer join和cross join的区别很多人不知道,我也是别人问起,才查找资料看了下,跟自己之前的认识差不多, 如果你使用join连表,缺陷的情况下是inn ...
- sql之left join、right join、inner join的区别,连接自己时的查询结果测试
sql之left join.right join.inner join的区别 left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括 ...
- SQL中inner join,outer join和cross join的区别
使用join连表,缺陷的情况下是inner join,开发中使用的left join和right join属于outer join,outer join还包括full join 现有两张表,Table ...
- 图解SQL inner join、left join、right join、full outer join、union、union all的区别
转于:http://justcoding.iteye.com/blog/2006487 这是一篇来自Coding Horror的文章. SQL的Join语法有很多:有inner的,有outer的,有l ...
- SQL夯实基础(一):inner join、outer join和cross join的区别
一.数据构建 先建表,再说话 create database Test use Test create table A ( AID ,) primary key, name ), age int ) ...
随机推荐
- bzoj 1914: [Usaco2010 OPen]Triangle Counting 数三角形 容斥
1914: [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 272 Sol ...
- hdu 4454 Stealing a Cake
简单的计算几何: 可以把0-2*pi分成几千份,然后找出最小的: 也可以用三分: #include<cstdio> #include<cmath> #include<al ...
- HttpResponseCache 网络缓存使用
Caches HTTP and HTTPS responses to the filesystem so they may be reused, saving time and bandwidth. ...
- oracle core04_undo
undo信息 oracle中undo的信息主要完成下面的功能: 1,构建块一致性读 2,回滚事务 UBA:undo block address 1,块中的事务槽ITL中的UBA表示这个ITL所在的bl ...
- oracle查询转换_view merge
oracle对于子查询的支持做的很好,oracle optimizer会对inline view进行query transfomation,即视图合并,不过也经常带来意想不到的问题.下面是一个inli ...
- WordPress Comment Attachment插件跨站脚本漏洞
漏洞名称: WordPress Comment Attachment插件跨站脚本漏洞 CNNVD编号: CNNVD-201310-062 发布时间: 2013-10-09 更新时间: 2013-10- ...
- BZOJ3210: 花神的浇花集会
3210: 花神的浇花集会 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 238 Solved: 119[Submit][Status] Descri ...
- Cocos2d-x 坑之二:目录改动后, cannot run on the selected destination
1:2dx开发中,目录改动后,经常会碰到这个提示错误: cannot run on the selected destination 解决方法:一般是因为 Info.plist文件属性问题,把 Ta ...
- Delphi 继承基类的窗体,并显示基类的控件操作。
1. 先建一个普通的窗体,until1 2. 先把类实现基类, 并需要实现基类需要继承的方法, 可以先不用再方法中写实现代码. TForm4 = class(TfrmmtAReportPeriod ...
- [MarsZ]ThinkPHP项目实战总结
本文原word格式百度云盘下载地址: http://pan.baidu.com/s/1qYqZFkg 综述 2 需求 2 作者 2 系统一览 2 Unity3d客户端 2 PHP后台 4 准备 6 X ...