通过加索引对sql语句优化
2024-08-25 07:09:30
今天看数据库的时候遇到这样一个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万的数据量,查询了很久都没有出来。后来网上找资料别人说第一要加上索引。后来给每个需要查询的列都加上了索引,速度快了很多。
最新文章
- 关于C# Winform DataGridView 设置DefaultCellStyle无效的原因与解决方案
- IPC----消息队列
- vmware workstation LINUX磁盘扩容
- Content Template &; DataTemplate 区别
- java.sql.DataTruncation: Data truncation
- Swagger 生成 ASP.NET Web API
- Oracle11g R2学习系列 之三教程选择
- Mysql 常用引擎的特点及选择使用策略
- JSP(基础语法)
- 10 分钟学会Linux常用 bash命令
- HDU 4162 	Shape Number(字符串,最小表示法)
- droid invalidate和postinvalidate的区别
- SSM框架下声明式事务管理(注解配置方式)
- centos中安装虚拟机
- SQL SERVER 基本操作语句
- 【刷题】AtCoder Regular Contest 003
- pandas.cut使用总结
- (转载)hibernate缓存
- 201621123012 《java程序设计》第5周学习总结
- 超强IIS站点工具一键设置PHP,支持多个PHP同时运行
热门文章
- [每日一题] 11gOCP 1z0-052 :2013-09-10 ABOUT ALERTS...............................................A50
- OpenGL 4 : 一个漂亮的心 For you, My Love
- CSS hank
- 解决No Hibernate Session bound to thread, and configuration does not allow creat。。。
- poj 1041 John's trip 欧拉回路
- chroot命令
- python自学笔记(八)python语句
- web附件中文名
- 扩展ASP.NET MVC HtmlHelper类
- 泛型 ";new的性能";