论坛首页 Java企业应用论坛

db2空记录查询要3秒,3表多次自关联,大家给点建议

浏览 3013 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-02-28   最后修改:2012-02-28

IWAQ0003W 发现了 SQL 警告
SQLState=01602 Performance of this complex query may be sub-optimal.  Reason code: "1".. SQLCODE=437, SQLSTATE=01602, DRIVER=4.12.79





SELECT
			  a.ID
			, a.PRTNAME
			, a.REGION
			, a.SAPPRTID
			, a.UNIT
			, a.FUNCTIONALITY
			, a.EDISTD
			, a.B2BGATEWAY
			, a.PLATFORM
			, a.CNTTYPE
			, a.CNTID
			, a.ONBRDOWNER
			, a.COMMENTS
			, a.CREATEDBY
			, a.CREATETIME
			, a.LASTMODIFIEDBY
			, a.LASTMODIFYTIME
		
			, b1.ITEM as REGIONNAME
			, b2.ITEM as UNITNAME
			, b3.ITEM as FUNCTIONALITYNAME
			, b4.ITEM as EDISTDNAME
			, b5.ITEM as B2BGATEWAYNAME
			, b6.ITEM as CNTTYPENAME
			, b7.ITEM as PLATFORMNAME
		
		FROM  
		      B2B_PARTNER a
		     		
			, B2B_DICT b1
			, B2B_DICT b2
			, B2B_DICT b3
			, B2B_DICT b4
			, B2B_DICT b5
			, B2B_DICT b6
			, B2B_DICT b7
		
			, B2B_TYPE c1
			, B2B_TYPE c2
			, B2B_TYPE c3
			, B2B_TYPE c4
			, B2B_TYPE c5
			, B2B_TYPE c6
			, B2B_TYPE c7
		WHERE   
		        a.ACTIVE = '1'
			AND c1.NAME = 'Region'
			AND a.REGION  = b1.ID
			AND b1.TYPE_ID = c1.ID
		
			AND c2.NAME = 'Business Unit'
			AND a.UNIT = b2.ID
			AND b2.TYPE_ID =c2.ID
		
			AND c3.NAME = 'Functionality'
			AND a.FUNCTIONALITY = b3.ID
			AND b3.TYPE_ID =c3.ID
		
			AND c4.NAME = 'EDI Standard'
			AND a.EDISTD = b4.ID
			AND b4.TYPE_ID =c4.ID
		
			AND c5.NAME = 'B2B Gateway'
			AND a.B2BGATEWAY = b5.ID
			AND b5.TYPE_ID =c5.ID
		
			AND c6.NAME = 'Connection Type'
			AND a.CNTTYPE = b6.ID
			AND b6.TYPE_ID =c6.ID
		
			AND c7.NAME = 'Internal Integration Platform'
			AND a.PLATFORM = b7.ID
			AND b7.TYPE_ID =c7.ID



   发表时间:2012-02-29  
今天优化了下,减少到31ms还不错
没有oracle 的decode真麻烦

SELECT
			  a.ID
			, a.PRTNAME
			, a.REGION
			, a.SAPPRTID
			, a.UNIT
			, a.FUNCTIONALITY
			, a.EDISTD
			, a.B2BGATEWAY
			, a.PLATFORM
			, a.CNTTYPE
			, a.CNTID
			, a.ONBRDOWNER
			, a.COMMENTS
			, a.CREATEDBY
			, a.CREATETIME
			, a.LASTMODIFIEDBY
			, a.LASTMODIFYTIME
		
			, b1.ITEM as REGIONNAME
			, b2.ITEM as UNITNAME
			, b3.ITEM as FUNCTIONALITYNAME
			, b4.ITEM as EDISTDNAME
			, b5.ITEM as B2BGATEWAYNAME
			, b6.ITEM as CNTTYPENAME
			, b7.ITEM as PLATFORMNAME
		
		FROM  
		      B2B_PARTNER a
		     		
			, B2B_DICT b1
			, B2B_DICT b2
			, B2B_DICT b3
			, B2B_DICT b4
			, B2B_DICT b5
			, B2B_DICT b6
			, B2B_DICT b7
		
		WHERE   
		        a.ACTIVE = '1'
			AND a.REGION  = b1.ID
			AND a.UNIT = b2.ID
			AND a.FUNCTIONALITY = b3.ID
			AND a.EDISTD = b4.ID
			AND a.B2BGATEWAY = b5.ID
			AND a.CNTTYPE = b6.ID
			AND a.PLATFORM = b7.ID

0 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics