SELECT查询N久都不出数据,但是加上top 1000就可以查出数据来,不知道是什么问题。
SELECT top 100 ISNULL(a.cid,0) AS cid, ISNULL(b.ID,0) AS sousid, a.keyid, a.intime,
ISNULL(dbo.convertvalue(a.sid),0) AS accessvalue,
ISNULL(dbo.convertelementdes_pagesum(a.sid),1) AS pagesumelement,
4 AS pagevalueelement,
ISNULL(dbo.convertelementdes_scantime(a.sid),1) AS scantimeelement,
ISNULL(dbo.convertelementdes_TelMsg(a.sid),1) AS TelMsgelement
FROM dbo.stat_session AS a
INNER JOIN dbo.stat_engine AS b ON CHARINDEX(b.url, a.frmurl, 8)> 0
WHERE a.keyid IS NOT NULL AND b.ID IN (1, 2, 8)
AND ISNULL(dbo.convertvalue(a.sid), 0)> 0 AND a.cid IN (SELECT ID FROM dt_company)
------解决方案--------------------一般都是因为连接条件没设置齐全导致记录几何增长
------解决方案--------------------a innert join b 的a表与b表的连接条件没设置
------解决方案--------------------数据量太大、、、、
------解决方案--------------------太多数据了吧 你要加上 top 10 速度才更快呢
------解决方案--------------------SELECT count(*)
FROM dbo.stat_session AS a
INNER JOIN dbo.stat_engine AS b ON CHARINDEX(b.url, a.frmurl, 8)> 0
WHERE a.keyid IS NOT NULL AND b.ID IN (1, 2, 8)
AND ISNULL(dbo.convertvalue(a.sid), 0)> 0 AND a.cid IN (SELECT ID FROM dt_company)
--看看数据量有多大
------解决方案--------------------就是用count(*)看看有多少条数据先
------解决方案--------------------海量数据啊.呵呵.
实际表中有没有这么多数据呢?
如果没有的话,那么就是语句连接条件设置不全,
或者是语句连接条件未进行优化.