StringBuffer sql = new StringBuffer();
sql.append("select t1.rloc_cd1 as pnrCode,");
sql.append("t1.pax_tp as paxTp,");
sql.append("t2.tkt_am as tktAm,");
sql.append("t2.tkt_ams as tktAms,");
sql.append("t2.tkt_no as tktNo,");
sql.append("t2.pax_cnm as paxCnm,");
sql.append("t2.pax_enm as paxEnm,");
sql.append("t2.op_sq as opSq,");
sql.append("t2.trans_sq as transSq,");
sql.append("t2.tax_am as taxAm,");
sql.append("t2.rout_dr as routDr,");
sql.append("t2.clas_tp as clasTps,");
sql.append("t2.carr_cd as carrCd,");
sql.append("t4.pass_no as passNo,");
sql.append("t4.pass_tp as passTp,");
sql.append("replace(t2.tkt_dt,'-','/') as tktDt ");
sql.append("from trtrans t1 inner join tttkt t2 on t1.op_sq = t2.op_sq and t1.trans_sq = t2.trans_sq ");
sql.append("inner join tttrecp t4 on t2.op_sq = t4.op_sq and t2.pax_sq=t4.pax_sq ");
sql.append("inner join tttrec t3 on t2.op_sq = t3.op_sq ");
sql.append("where t2.tkt_no="+tktNo);
sql.append(" and rownum<=1 order by t2.op_sq desc");
List tktVoList= jdbcTemplate.queryForList(sql.toString());
TktVO tktVO = new TktVO();
for(int i=0;i<tktVoList.size();i++){
Map map=(Map)tktVoList.get(i);
tktVO.setPnrCode((String)map.get("pnrCode"));
tktVO.setPaxT((String)map.get("paxTp"));
BigDecimal tktAm=(BigDecimal)map.get("tktAm");
tktVO.setTktM(tktAm.intValue());
BigDecimal tktAms=(BigDecimal)map.get("tktAms");
tktVO.setTktAms(tktAms.intValue());
tktVO.setTktNo((String)map.get("tktNo"));
tktVO.setPaxCnm((String)map.get("paxCnm"));
tktVO.setPaxEnm((String)map.get("paxEnm"));
tktVO.setOpSq((String)map.get("opSq"));
tktVO.setTransSq((String)map.get("transSq"));
BigDecimal taxAm=(BigDecimal)map.get("taxAm");
tktVO.setTaxAm(taxAm.intValue());
tktVO.setRoutDr((String)map.get("routDr"));
tktVO.setClasTps((String)map.get("clasTps"));
tktVO.setCarrCd((String)map.get("carrCd"));
tktVO.setPassNo((String)map.get("passNo"));
tktVO.setPassTp((String)map.get("passTp"));
tktVO.setTktDt((String)map.get("tktDt"));
}
看执行计划,加索引
不奇怪啊,没有参照系,也许40S也算是快的。
没有参照系是什么意思?
sql慢的解决办法就那几个.不多说啦.
我说题外话..你们公司是按行数算绩效的吗?
说这里代码可以不用这么复杂吗?
天下如此不安宁~~~~ 遍地都是这样的奇葩,不 —— 其实我们才是那朵奇葩。
从明天开始准备好好练习dos
4秒,已经很快了!我们一个出报表的SQL,要跑90-100秒啊。
多说一句:你在问大家为什么一条SQL跑得慢,那你就简简单单地给我们看那条你要执行的SQL语句,然后简单说明一下它所设计到的几张表的基本情况,就好了。
你贴这一堆JAVA代码是几个意思?
说不定是JDBCTEMP问题