今天看数据库的时候遇到这样一个SQL语句:

select

substr(a.djxh,6) as id,
(a.nd || a.yf) DECL_YM,
a.zspm_dm as LEVY_ITEM_ID,
b.zsxmmc as LEVY_ITEM_NAME, --||'--'||d.zspmmc
100 as DECL_STATUS,
a.nsqx_dm as TAX_TERM_CODE,
c.nsqxmc as TAX_TERM_NAME,
to_char(a.sbqx, 'yyyyMMdd') as DECL_TREM,
to_char(a.sjtb_sj, 'yyyyMM') as DATA_CREATE_YM,
a.sjgsdq as area_code
from
(
select djxh, nd, yf, zspm_dm, nsqx_dm, sbqx, sjtb_sj, sjgsdq,zsxm_dm
from tci.sb_ysbtj
where zfbz_1 is null
or zfbz_1 = 'N'
and exists (select *
from (select to_number('' || i.id) as iid
from i_reg_account i
where mgr_dept in
(select t.org_id
from i_organization t
where t.isdirectguanhu = 1
start with (t.org_id = 24300900000)
connect by prior t.org_id = t.parent_id)) d
where djxh = iid)
and trim(yf) = to_char(sysdate, 'MM')
and nd = to_char(SysDate, 'YYYY') ) a left join dm_gy_zsxm b
on a.zsxm_dm = b.zsxm_dm
left join dm_gy_nsqx c
on a.nsqx_dm = c.nsqx_dm

sb_ysbtj有900万的数据量,查询了很久都没有出来。后来网上找资料别人说第一要加上索引。后来给每个需要查询的列都加上了索引,速度快了很多。

最新文章

  1. 关于C# Winform DataGridView 设置DefaultCellStyle无效的原因与解决方案
  2. IPC----消息队列
  3. vmware workstation LINUX磁盘扩容
  4. Content Template & DataTemplate 区别
  5. java.sql.DataTruncation: Data truncation
  6. Swagger 生成 ASP.NET Web API
  7. Oracle11g R2学习系列 之三教程选择
  8. Mysql 常用引擎的特点及选择使用策略
  9. JSP(基础语法)
  10. 10 分钟学会Linux常用 bash命令
  11. HDU 4162 Shape Number(字符串,最小表示法)
  12. droid invalidate和postinvalidate的区别
  13. SSM框架下声明式事务管理(注解配置方式)
  14. centos中安装虚拟机
  15. SQL SERVER 基本操作语句
  16. 【刷题】AtCoder Regular Contest 003
  17. pandas.cut使用总结
  18. (转载)hibernate缓存
  19. 201621123012 《java程序设计》第5周学习总结
  20. 超强IIS站点工具一键设置PHP,支持多个PHP同时运行

热门文章

  1. [每日一题] 11gOCP 1z0-052 :2013-09-10 ABOUT ALERTS...............................................A50
  2. OpenGL 4 : 一个漂亮的心 For you, My Love
  3. CSS hank
  4. 解决No Hibernate Session bound to thread, and configuration does not allow creat。。。
  5. poj 1041 John's trip 欧拉回路
  6. chroot命令
  7. python自学笔记(八)python语句
  8. web附件中文名
  9. 扩展ASP.NET MVC HtmlHelper类
  10. 泛型 "new的性能"