自定义函数导致的sql性能问题
同事说,某某报表跑的很慢,让我调查一下
优化前:该报表整体需要跑4小时以上。
sql代码如下
SELECT /*省略多数查询字段*/
REP_FUN_REFCODEVALUE /*自定义函数*/
(P.POLICYTYPE, '3') AS POLICYTYPE,
REP_FUN_REFCODEVALUE /*自定义函数*/
(P.POLICYSTATUS, '3') AS POLICY_STATUS,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.AMOUNT_BP AS RMB_AMOUNT_BP,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.RI_PREM_BP AS RMB_RI_PREM_BP,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T3.UWCURRENCY, '$$100001000001'), '201706') * T3.SUMINSURED AS RMB_GROSS_TSI,
REP_FUN_POLICY_COMBINESTRING /*自定义函数*/
(P.POLICYNO, P.ENDORSEMENTNO, 'CODE') AS CBI_CODE,
REP_FUN_POLICY_COMBINESTRING /*自定义函数*/
(P.POLICYNO, P.ENDORSEMENTNO, 'NAME') AS CBI_NAME,
REP_FUN_POLICY_COMBINESTRING /*自定义函数*/
(P.POLICYNO, P.ENDORSEMENTNO, 'EQCODE') AS EQ_CODE,
REP_FUN_POLICY_COMBINESTRING(P.POLICYNO, P.ENDORSEMENTNO, 'EQNAME') AS EQ_NAME,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.AMOUNTVAT_BP,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.AMOUNTNET_BP,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.RI_PREMVAT_BP,
REP_FUN_BP_EXCHANGERATE_BOM /*自定义函数*/
(NVL(T.POLICYCURRENCYCODE, '$$100001000001'), FLAG) * T.RI_PREMNET_BP,
REP_RI_COMMISSIONVAT /*自定义函数*/(T.RIBILLNO),
REP_RI_COMMISSION /*自定义函数*/(T.RIBILLNO)
FROM BIZ_BP_CHECK_BP_BASED_CEDOUT T
LEFT JOIN (SELECT T.RIBILLNO,
T.OPTTYPE,
T.CONTRACTTYPE,
T.QSTYPE,
DECODE(T.OPTTYPE || '-' || T.CONTRACTTYPE || '-' ||
T.QSTYPE,
'1-2-Q',
'分入-合约-成数',
'1-2-C',
'分入-合约-超赔',
'1-2-S',
'分入-合约-溢额',
'1-2-Y',
'分入-合约-成数溢额',
'1-4-Q',
'分入-临分-成数',
'1-4-C',
'分入-临分-超赔',
'1-4-S',
'分入-临分-溢额',
'1-4-Y',
'分入-临分-成数溢额',
'0-2-Q',
'分出-合约-成数',
'0-2-C',
'分出-合约-超赔',
'0-2-S',
'分出-合约-溢额',
'0-2-Y',
'分出-合约-成数溢额',
'0-4-Q',
'分出-临分-成数-原保',
'2-4-Q',
'分出-临分-成数-再保',
'0-4-C',
'分出-临分-超赔-原保',
'2-4-C',
'分出-临分-超赔-再保',
'0-4-S',
'分出-临分-溢额-原保',
'2-4-S',
'分出-临分-溢额-再保',
'0-4-Y',
'分出-临分-成数溢额-原保',
'2-4-Y',
'分出-临分-成数溢额-再保',
NULL) AS RESULT_NAME
FROM RPT_ST.RI_I_BPACCOUNT T
GROUP BY T.RIBILLNO, T.OPTTYPE, T.CONTRACTTYPE, T.QSTYPE) I
ON I.RIBILLNO = T.RIBILLNO
LEFT JOIN RPT_ST.RI_POLICY RI_POLICY
ON T.POLICYNO = RI_POLICY.CED_POLICY_NO
LEFT JOIN RPT_ST.ACCOUNT_CATALOG ACCOUNT_CATALOG
ON ACCOUNT_CATALOG.BILL_NO = T.RIBILLNO
LEFT JOIN (SELECT STATEMENT_NO, REINSURER_NO, FAC_CONT_ID
FROM RPT_ST.RI_FAC_CONT_REINS_FIN
GROUP BY STATEMENT_NO, REINSURER_NO, FAC_CONT_ID) T5
ON T.RIBILLNO = T5.STATEMENT_NO
LEFT JOIN (SELECT T7.FAC_CONT_ID,
T7.REINSURER_NO,
T7.TAX_RATE,
T7.BROKER_RATE
FROM RPT_ST.RI_FAC_CONT_REINS T7) T7
ON T5.FAC_CONT_ID = T7.FAC_CONT_ID
AND T5.REINSURER_NO = T7.REINSURER_NO
LEFT JOIN TEL_CED_OUT_BROKERS OUT_BROKERS
ON T5.FAC_CONT_ID = OUT_BROKERS.FAC_CONT_ID
AND T5.REINSURER_NO = OUT_BROKERS.REINSURER_NO
LEFT JOIN TEL_CED_IN_BROKERS IN_BROKERS
ON T.POLICYNO = IN_BROKERS.CED_POLICY_NO
LEFT JOIN TEL_UNION_SUMMARY_NOS UNION_SUMMARY_NOS
ON T.POLICYNO = UNION_SUMMARY_NOS.POLICYNO
LEFT JOIN RPT_ST.RI_FAC_CONT T6
ON T5.FAC_CONT_ID = T6.FAC_CONT_ID
LEFT JOIN (SELECT DISTINCT (CONTRACTCODE) AS CONTRACTCODE, RIBILLNO
FROM RPT_ST.RI_I_BPACCOUNT) T9
ON T9.RIBILLNO = T.RIBILLNO
LEFT JOIN RPT_ST.CES_RST T8
ON ACCOUNT_CATALOG.CES_RESULTID = T8.RESULT_ID
LEFT JOIN RPT_ST.T_ORGANIZATION_VIEW OV
ON RI_POLICY.DEPT_CODE = OV.ORGANIZATIONCODE
LEFT JOIN IF_UW_POLICYBASICINFO P
ON P.POLICYNO = T.POLICYNO
AND P.ENDORSEMENTNO = T.ENDORSEMENTNO
LEFT JOIN (SELECT T.POLICYNO, MIN(T.ACCOUNTINGDATE) AS ACCOUNTINGDATE
FROM BIZ_BP_CHECK_BP_BASED T
GROUP BY T.POLICYNO) BIZ_BP_BASED
ON BIZ_BP_BASED.POLICYNO = T.POLICYNO
LEFT JOIN REP_V_POLICYPREMIUMIN_ALL T3
ON P.TOPACTUALID = T3.TOPACTUALID
WHERE T.FLAG = '201706'
AND T.COMPARE_FLAG = 'N';
分析步骤
- 确认性能瓶颈
抓取到以上sql后,首先拿到测试环境运行,发现如下问题,能在20分钟内出结果,但是要刷出全部结果,却需要 >2h
分析sql,发现其查询字段中,带有很多自定义函数 rep_fun,去掉分析函数,sql能在1分内刷出全部结果。
由此可以确定该sql的性能问题,出在自定义函数上。
- 分析自定义函数
函数REP_FUN_POLICY_COMBINESTRING
CREATE OR REPLACE FUNCTION REP_FUN_POLICY_COMBINESTRING( policy_no IN VARCHAR2
,endorsement_no IN VARCHAR2
,flags IN VARCHAR2) RETURN VARCHAR2 IS
V_POLICYNO_INPUT VARCHAR2(30);
V_ENDORSEMENTNO_INPUT VARCHAR2(30);
V_FLAGS_INPUT VARCHAR2(10);
V_RETURN_VALUE VARCHAR2(500); --返回值
BEGIN
V_POLICYNO_INPUT := policy_no;
V_ENDORSEMENTNO_INPUT := endorsement_no;
V_FLAGS_INPUT := flags;
If NVL(V_POLICYNO_INPUT,'')='' OR NVL(V_ENDORSEMENTNO_INPUT,'')='' OR NVL(V_FLAGS_INPUT,'')='' Then
Return Null;
Else
If V_FLAGS_INPUT = 'CODE' Then
select
MAX(decode(t.clausecode,'P-013',t.clausecode||';',NULL)) ||
MAX(decode(t.clausecode,'P-013B',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-013C',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-013A',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-013D',t.clausecode||';',NULL)) ||
MAX(decode(t.clausecode,'P-013E',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-116',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-116B',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-116C',t.clausecode||';',NULL)) ||
MAX(decode(t.clausecode,'P-116A',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-116D',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-116E',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P-074',t.clausecode||';',NULL)) ||
MAX(decode(t.clausecode,'P-075',t.clausecode||';',NULL))
INTO V_RETURN_VALUE
from if_uw_policyclauses t
where policyno=V_POLICYNO_INPUT
AND ENDORSEMENTNO=V_ENDORSEMENTNO_INPUT
GROUP BY t.policyno,t.ENDORSEMENTNO;
If length(NVL(V_RETURN_VALUE,' '))>1 Then
V_RETURN_VALUE := substr(V_RETURN_VALUE,1,length(V_RETURN_VALUE)-1);
End If;
Return V_RETURN_VALUE;
Elsif V_FLAGS_INPUT = 'NAME' Then
select
MAX(decode(t.clausecode,'P-013',t.clausename||';',NULL)) ||
MAX(decode(t.clausecode,'P-013B',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-013C',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-013A',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-013D',t.clausename||';',NULL)) ||
MAX(decode(t.clausecode,'P-013E',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-116',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-116B',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-116C',t.clausename||';',NULL)) ||
MAX(decode(t.clausecode,'P-116A',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-116D',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-116E',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P-074',t.clausename||';',NULL)) ||
MAX(decode(t.clausecode,'P-075',t.clausename||';',NULL))
INTO V_RETURN_VALUE
from if_uw_policyclauses t
where policyno=V_POLICYNO_INPUT
AND ENDORSEMENTNO=V_ENDORSEMENTNO_INPUT
GROUP BY t.policyno,t.ENDORSEMENTNO;
If length(NVL(V_RETURN_VALUE,' '))>1 Then
V_RETURN_VALUE := substr(V_RETURN_VALUE,1,length(V_RETURN_VALUE)-1);
End If;
Return V_RETURN_VALUE;
Elsif V_FLAGS_INPUT = 'EQCODE' then
select
MAX(decode(t.clausecode,'P-003',t.clausecode||';',NULL))||
MAX(decode(t.clausecode,'P021',t.clausecode||';',NULL))
INTO V_RETURN_VALUE
from if_uw_policyclauses t
where policyno=V_POLICYNO_INPUT
AND ENDORSEMENTNO=V_ENDORSEMENTNO_INPUT
GROUP BY t.policyno,t.ENDORSEMENTNO;
If length(NVL(V_RETURN_VALUE,' '))>1 Then
V_RETURN_VALUE := substr(V_RETURN_VALUE,1,length(V_RETURN_VALUE)-1);
End If;
Return V_RETURN_VALUE;
Elsif V_FLAGS_INPUT = 'EQNAME' then
select
MAX(decode(t.clausecode,'P-003',t.clausename||';',NULL))||
MAX(decode(t.clausecode,'P021',t.clausename||';',NULL))
INTO V_RETURN_VALUE
from if_uw_policyclauses t
where policyno=V_POLICYNO_INPUT
AND ENDORSEMENTNO=V_ENDORSEMENTNO_INPUT
GROUP BY t.policyno,t.ENDORSEMENTNO;
If length(NVL(V_RETURN_VALUE,' '))>1 Then
V_RETURN_VALUE := substr(V_RETURN_VALUE,1,length(V_RETURN_VALUE)-1);
End If;
Return V_RETURN_VALUE;
Else
Return Null;
End If;
End If;
End;
单独运行函数中select语句,发现其的访问路径为“全表扫描”,且分组函数是MAX,所以可以在(policyno,ENDORSEMENTNO)上建立组合索引。
函数REP_RI_COMMISSIONVAT
CREATE OR REPLACE FUNCTION REP_RI_COMMISSIONVAT(RIBILLNO IN VARCHAR2)
RETURN NUMBER AS
V_RIBILLNO VARCHAR2(100); --输入的zb账单号
V_COMMISSION_IT NUMBER; --手续费增值税
--V_tax number;--税
V_COMMISSIONVAT NUMBER; --手续费增值税,返回值
BEGIN
V_RIBILLNO := RIBILLNO;
IF V_RIBILLNO IS NOT NULL THEN
SELECT NVL(SUM(VATAMOUNT), 0)
INTO V_COMMISSION_IT ---手续费增值税
FROM RI_I_BPACCOUNT_V
WHERE RIBILLNO = V_RIBILLNO
--- and datatype='08';---8285
AND DATATYPE IN ('08', '24');
V_COMMISSIONVAT := V_COMMISSION_IT;
END IF;
RETURN(V_COMMISSIONVAT);
EXCEPTION
WHEN OTHERS THEN
RETURN V_COMMISSIONVAT;
END;
把自定义函数改成left join(为什么改成left join,因为IF V_RIBILLNO IS NOT NULL THEN 才会处理逻辑,而不为空的直接null。)
例如:
select b.V_COMMISSION1
from BIZ_BP_CHECK_BP_BASED_CEDOUT t
left join (SELECT ribillno, nvl(sum(netamount), 0) V_COMMISSION1
FROM ri_i_bpaccount_v
WHERE datatype in ('08', '24')
group by ribillno) b
on b.ribillno = t.ribillno
函数REP_RI_COMMISSION
CREATE OR REPLACE FUNCTION REP_RI_COMMISSION (RIBILLNO IN VARCHAR2)
RETURN NUMBER
AS
V_RIBILLNO VARCHAR2(100); --输入的zb账单号
V_COMMISSION_IT number;--含税手续费
--V_tax number;--税
V_COMMISSION number;--不含税手续费,返回值
BEGIN
V_RIBILLNO := RIBILLNO ;
IF V_RIBILLNO IS NOT NULL THEN
SELECT nvl(sum(netamount),0)
INTO V_COMMISSION_IT ---含税手续费
FROM ri_i_bpaccount_v
WHERE ribillno = V_RIBILLNO
--- and datatype='08';---8285
and datatype in ('08','24')
group by ribillno;
V_COMMISSION:=V_COMMISSION_IT;
END IF ;
RETURN( V_COMMISSION );
EXCEPTION
WHEN OTHERS
THEN
RETURN V_COMMISSION;
END;
把自定义函数改成left join(为什么改成left join,因为IF V_RIBILLNO IS NOT NULL THEN 才会处理逻辑,而不为空的直接null。)
例如:
SELECT C.V_COMMISSIONVAT2
FROM BIZ_BP_CHECK_BP_BASED_CEDOUT T
LEFT JOIN (SELECT NVL(SUM(VATAMOUNT), 0) V_COMMISSIONVAT2, RIBILLNO
FROM RI_I_BPACCOUNT_V
WHERE DATATYPE IN ('08', '24')
GROUP BY RIBILLNO) C
ON T.RIBILLNO = C.RIBILLNO
优化后整体代码
耗时:45s能返回全部结果
select
REP_FUN_REFCODEVALUE(p.policystatus, '3') as policy_status,
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.amount_bp as RMB_amount_bp,
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.ri_prem_bp as RMB_ri_prem_bp,
REP_FUN_REFCODEVALUE(p.marinecargotype, '1'), --进出口标志
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T3.Uwcurrency, '$$100001000001'),
'201706') * t3.suminsured as RMB_Gross_TSI, --保额
REP_FUN_POLICY_COMBINESTRING(p.policyno, p.endorsementno, 'CODE') as CBI_CODE, --CBI代码
REP_FUN_POLICY_COMBINESTRING(p.policyno, p.endorsementno, 'NAME') as CBI_NAME, --CBI名称
REP_FUN_POLICY_COMBINESTRING(p.policyno, p.endorsementno, 'EQCODE') as EQ_CODE, --EQ 代码
REP_FUN_POLICY_COMBINESTRING(p.policyno, p.endorsementno, 'EQNAME') as EQ_NAME, --EQ 名称
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.AMOUNTVAT_BP,
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.AMOUNTNET_BP,
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.RI_PREMVAT_BP,
REP_FUN_BP_EXCHANGERATE_BOM(NVL(T.Policycurrencycode,
'$$100001000001'),
FLAG) * t.RI_PREMNET_BP,
/* REP_RI_COMMISSIONVAT(t.riBILLNO),
REP_RI_COMMISSION(t.riBILLNO),*/
b.V_COMMISSION1,
C.V_COMMISSIONVAT2,
from BIZ_BP_CHECK_BP_BASED_CEDOUT t
left join (SELECT ribillno, nvl(sum(netamount), 0) V_COMMISSION1
FROM ri_i_bpaccount_v
WHERE datatype in ('08', '24')
group by ribillno) b
on b.ribillno = t.ribillno
LEFT JOIN (SELECT NVL(SUM(VATAMOUNT), 0) V_COMMISSIONVAT2, RIBILLNO
FROM RI_I_BPACCOUNT_V
WHERE DATATYPE IN ('08', '24')
GROUP BY RIBILLNO) C
ON T.RIBILLNO = C.RIBILLNO
left join (select t.ribillno,
t.OPTTYPE,
t.contracttype,
t.qstype,
decode(t.OPTTYPE || '-' || t.contracttype || '-' ||
t.qstype,
'1-2-Q',
'分入-合约-成数',
'1-2-C',
'分入-合约-超赔',
'1-2-S',
'分入-合约-溢额',
'1-2-Y',
'分入-合约-成数溢额',
'1-4-Q',
'分入-临分-成数',
'1-4-C',
'分入-临分-超赔',
'1-4-S',
'分入-临分-溢额',
'1-4-Y',
'分入-临分-成数溢额',
'0-2-Q',
'分出-合约-成数',
'0-2-C',
'分出-合约-超赔',
'0-2-S',
'分出-合约-溢额',
'0-2-Y',
'分出-合约-成数溢额',
'0-4-Q',
'分出-临分-成数-原保',
'2-4-Q',
'分出-临分-成数-再保',
'0-4-C',
'分出-临分-超赔-原保',
'2-4-C',
'分出-临分-超赔-再保',
'0-4-S',
'分出-临分-溢额-原保',
'2-4-S',
'分出-临分-溢额-再保',
'0-4-Y',
'分出-临分-成数溢额-原保',
'2-4-Y',
'分出-临分-成数溢额-再保',
null) AS RESULT_NAME
from rpt_st.Ri_i_Bpaccount t
group by t.ribillno, t.OPTTYPE, t.contracttype, t.qstype) i
on i.ribillno = t.ribillno
left join rpt_st.ri_policy ri_policy
on t.policyno = ri_policy.ced_policy_no
left join rpt_st.ACCOUNT_CATALOG ACCOUNT_CATALOG
on ACCOUNT_CATALOG.BILL_NO = t.ribillno
left join (select statement_no, REINSURER_NO, fac_cont_id
from rpt_st.Ri_Fac_Cont_Reins_Fin
group by statement_no, REINSURER_NO, fac_cont_id) t5
on t.ribillno = t5.statement_no
left join (select t7.fac_cont_id,
t7.REINSURER_NO,
t7.TAX_RATE,
t7.BROKER_RATE
from rpt_st.Ri_Fac_Cont_Reins t7) t7
on t5.fac_cont_id = t7.fac_cont_id
and t5.REINSURER_NO = t7.REINSURER_NO
left join TEL_CED_OUT_BROKERS OUT_BROKERS
on t5.fac_cont_id = OUT_BROKERS.Fac_Cont_Id
and t5.REINSURER_NO = OUT_BROKERS.REINSURER_NO
left join TEL_CED_IN_BROKERS IN_BROKERS
on t.policyno = IN_BROKERS.CED_POLICY_NO
left join TEL_union_summary_nos union_summary_nos
on t.policyno = union_summary_nos.policyno
left join rpt_st.Ri_Fac_Cont t6
on t5.fac_cont_id = t6.fac_cont_id
left join (select distinct (contractcode) as contractcode, ribillno
from rpt_st.ri_i_bpaccount) t9
on t9.ribillno = t.ribillno
left join rpt_st.ces_rst t8
on ACCOUNT_CATALOG.ces_resultid = t8.result_id
left join rpt_st.t_Organization_View ov
on ri_policy.dept_code = ov.organizationcode
left join if_uw_policybasicinfo P
on P.Policyno = t.policyno
and P.Endorsementno = t.Endorsementno
left join (select t.policyno, min(t.accountingdate) as accountingdate
from BIZ_BP_CHECK_BP_BASED t
group by t.policyno) BIZ_BP_BASED
on BIZ_BP_BASED.Policyno = t.policyno
left join REP_V_POLICYPREMIUMIN_all t3
ON p.topactualid = T3.topactualid
where t.flag = '201706'
and t.compare_flag = 'N'
自定义函数导致的sql性能问题的更多相关文章
- KingbaseES 函数稳定性与SQL性能
背景:客户现场的一次艰苦的调优过程(https://www.cnblogs.com/kingbase/p/16015834.html),让我觉得非常有必要让数据库用户了解函数的不同稳定性属性,及其对于 ...
- MS SQL自定义函数IsPositiveInteger MS SQL自定义函数IsNumeric 水晶报表使用IEnumerable<T>数据源
MS SQL自定义函数IsPositiveInteger 判断字符串是否为正整数,0开始的的数字不算. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON ...
- 自定义函数执行动态sql语句
--函数中不能调用动态SQL,使用用存储过程吧.如果还要对函数做其他操作,换成存储过程不方便,可以考虑把其他操作一起封装在存储过程里面.如: create proc [dbo].[FUN_YSCL ...
- 自定义函数动态执行SQL语句
Oracle 动态SQL有两种写法:用 DBMS_SQL 或 execute immediate,建议使用后者. DDL 和 DML Sql代码 收藏代码 /*** DDL ***/ begin EX ...
- MySQL字符集不一致导致查询SQL性能问题
今天做了一个MySQL数据库中的SQL优化. 结论是关联字段字符集不同,导致索引不可用. 查询的SQL如下: select `Alias`.`Grade`, `Alias`.`id`, `Alias` ...
- 在SQL中使用自定义函数
由于数据库的一个表字段中多包含html标签,现在需要修改数据库的字段把html标签都替换掉.当然我可以通过写一个程序去修改,那毕竟有点麻烦.直接在查询分析器中执行,但是MS SQL Server并 ...
- Oracle DB SQL 性能分析器
• 确定使用SQL 性能分析器的优点 • 描述SQL 性能分析器工作流阶段 • 使用SQL 性能分析器确定数据库更改所带来的性能改进 SQL 性能分析器:概览 • 11g 的新增功能 • 目标用户:D ...
- 【转】MYSQL入门学习之十三:自定义函数的基本操作
转载地址:http://www.2cto.com/database/201212/177382.html 一.自定义函数(UDF)的特性和功能 www.2cto.com 函数能分 ...
- SQL Server如何定位自定义标量函数被那个SQL调用次数最多浅析
前阵子遇到一个很是棘手的问题,监控系统DPA发现某个自定义标量函数被调用的次数非常高,高到一个离谱的程度.然后在Troubleshooting这个问题的时候,确实遇到了一些问题让我很是纠结,下文是解决 ...
随机推荐
- 3dmax学习资料记录
max2015 官方文档 http://help.autodesk.com/view/3DSMAX/2015/CHS/?guid=GUID-D015E335-EFB3-43BF-AB27-C3CB09 ...
- Visual Studio 的Build Event 使用
rmdir Configuration mkdir Configuration Copy "$(ProjectDir)Configuration\Spec.config" &quo ...
- 前端开发常用cmd命令
windows打开命令行 开始->运行->键入cmd 也可通过附件查找到命令提示符,右键属性为其设置快捷键 快捷键 更改路径 d: // 切换到d盘 cd <fold ...
- pycharm 断点调试
转自; https://blog.csdn.net/chenggong2dm/article/details/9368641 PyCharm 作为IDE,断点调试是必须有的功能.否则,我们还真不如用纯 ...
- Codeforces Round #410 (Div. 2) C
Description Mike has a sequence A = [a1, a2, ..., an] of length n. He considers the sequence B = [b1 ...
- DP HDOJ 5492 Find a path
题目传送门 题意:从(1, 1)走到(n, m),每次往右或往下走,问(N+M−1)∑(Ai−Aavg)2 的最小值 分析:展开式子得到(N+M−1)∑(Ai2) - (∑(Ai))2的最小值.用普通 ...
- centOS 部署服务器(二)
(1)安装nginx 1.下载地址: http://nginx.org/en/download.html ,并解压到目录下 2.安装依赖包 yum -y install pcre* yum -y i ...
- Zernike矩之边缘检测(附源码)
这一篇博文将讨论Zernike矩在边缘检测中的应用,关于Zernike矩的基本概念,可以参看<Zernike矩之图像重建(附源码> 源码下载 参考: [4] Ghosal S, Mehro ...
- iOS7改变状态栏文字颜色
1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的 AppDelegate中在 didFinishLaun ...
- oracle 10g standby 设置
##########sample alter system set log_archive_dest_1 = 'LOCATION=USE_DB_RECOVERY_FILE_DEST' scope=bo ...