|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
大家好
我是这个论坛新来的,以后请大家多多关照
现在我有一个比较棘手的问题想请教
下边是我现在运行的一个SQL语句
SELECT H_HANDIN.DH_ID, H_HANDIN.DH_ID_REFER, H_HANDIN.DLTK_BEGINDATE, H_HANDIN.DLTK_ENDDATE,
H_HANDIN.RTA_ACCOUNT_ID, H_HANDIN.DH_DATE, H_HANDIN.DH_LIMITDATE, H_HANDIN.DH_HANDNUMBER,
H_HANDIN.DH_TAX_ATTRIBUTE, H_HANDIN.DH_COMMENT, H_HANDIN.DH_ACCNAME, H_HANDIN.DH_INCOME,
H_HANDIN.DH_BACKDATE, H_HANDIN.DH_CHECKDATE, H_HANDIN.DLTK_REGDATE, H_HANDIN.DH_HOSTNUM,
H_HANDIN.DH_HANDNUM, H_HANDIN.DH_NAME, H_HANDIN.DH_LATENUM, H_HANDIN.DH_ADDRESS,
H_HANDIN.DH_DENID, H_HANDIN.RTP_SOCIAL, H_HANDIN.DH_WORKDATE, H_HANDIN.DH_NO,
H_HANDIN.MAKE_AVID, H_HANDIN.DEPOT_AVID, H_HANDIN.DLTK_ID, H_HANDIN.BTO_ID,
H_HANDIN.DH_BTOID, H_HANDIN.DH_WORKER, H_HANDIN.BTOF_ID, H_HANDIN.DH_ANNNULMAN,
H_HANDIN.DH_REGMAN, H_HANDIN.RTP_ID, H_HANDIN.BCB_ID, H_HANDIN.BS_ID, H_HANDIN.BC_ID,
H_HANDIN.AAB_ID, H_HANDIN.IIT_ID, H_HANDIN.MPT_ID, H_HANDIN.MLT_ID, H_HANDIN.MFT_ID,
H_HANDIN.DH_BACKTYPE, H_HANDIN.DH_OWETYPE, H_HANDIN.BTK_ID, H_HANDIN.INPUT_MBLID,
H_HANDIN.FIX_MCFID, H_HANDIN_ADD.DHA_NUMBER, H_HANDIN_ADD.DHA_BIT, H_HANDIN_ADD.DHA_MUSTNUM,
H_HANDIN_ADD.MBI_ID, H_HANDIN_ADD.BTK_ID, H_HANDIN_ADD.MBI_FUND, H_HANDIN_ADD.INPUT_MBLID,
H_HANDIN_ADD.DHA_ESCAPENUMBER
FROM
H_HANDIN, H_HANDIN_ADD
WHERE
H_HANDIN.DH_STATUS<>0
AND H_HANDIN_ADD.DHA_MUSTNUM<>0
AND H_HANDIN.IIT_ID<>'9903'
AND H_HANDIN.EFFECTIVE_DATE>'2008-6-24'
AND DATEDIFF(DAY, H_HANDIN.EFFECTIVE_DATE, GETDATE())>0
AND
H_HANDIN.DH_NO=H_HANDIN_ADD.DH_NO;
这个语句中的两张表的数据都是属于千万级别的数据,现在这个语句运行起来需要3个多小时,我经过仔细排查,发现问题在于H_HANDIN.EFFECTIVE_DATE>'2008-6-24' 这句话上,如果我把后边的日期值改为2006-6-24,则查询只需要一个多小时,后来我发现我把日期一直往前加,分别改为2007-6-24,2007-12-24,2008-1-1,2008-5-1,2008-6-1时间越来越慢,但是都不会差多少,
因为那个EFFECTIVE_DATE是做业务的时间,后边的日期值是上次语句运行的时间,当时这个语句在2008-6-1日运行的时候也是三个多小时,
也就是说现在的现象是日期值越和EFFECTIVE_DATE的最新日期越接近运行越慢
哪位高手能帮忙解决一下这个问题,谢谢了
小弟比较着急,小弟对SYbase还在学习阶段,谢谢了 |
|