同事说,某某报表跑的很慢,让我调查一下

优化前:该报表整体需要跑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性能问题的更多相关文章

  1. KingbaseES 函数稳定性与SQL性能

    背景:客户现场的一次艰苦的调优过程(https://www.cnblogs.com/kingbase/p/16015834.html),让我觉得非常有必要让数据库用户了解函数的不同稳定性属性,及其对于 ...

  2. MS SQL自定义函数IsPositiveInteger MS SQL自定义函数IsNumeric 水晶报表使用IEnumerable<T>数据源

    MS SQL自定义函数IsPositiveInteger   判断字符串是否为正整数,0开始的的数字不算. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON ...

  3. 自定义函数执行动态sql语句

    --函数中不能调用动态SQL,使用用存储过程吧.如果还要对函数做其他操作,换成存储过程不方便,可以考虑把其他操作一起封装在存储过程里面.如:   create proc [dbo].[FUN_YSCL ...

  4. 自定义函数动态执行SQL语句

    Oracle 动态SQL有两种写法:用 DBMS_SQL 或 execute immediate,建议使用后者. DDL 和 DML Sql代码 收藏代码 /*** DDL ***/ begin EX ...

  5. MySQL字符集不一致导致查询SQL性能问题

    今天做了一个MySQL数据库中的SQL优化. 结论是关联字段字符集不同,导致索引不可用. 查询的SQL如下: select `Alias`.`Grade`, `Alias`.`id`, `Alias` ...

  6. 在SQL中使用自定义函数

      由于数据库的一个表字段中多包含html标签,现在需要修改数据库的字段把html标签都替换掉.当然我可以通过写一个程序去修改,那毕竟有点麻烦.直接在查询分析器中执行,但是MS SQL Server并 ...

  7. Oracle DB SQL 性能分析器

    • 确定使用SQL 性能分析器的优点 • 描述SQL 性能分析器工作流阶段 • 使用SQL 性能分析器确定数据库更改所带来的性能改进 SQL 性能分析器:概览 • 11g 的新增功能 • 目标用户:D ...

  8. 【转】MYSQL入门学习之十三:自定义函数的基本操作

    转载地址:http://www.2cto.com/database/201212/177382.html 一.自定义函数(UDF)的特性和功能  www.2cto.com           函数能分 ...

  9. SQL Server如何定位自定义标量函数被那个SQL调用次数最多浅析

    前阵子遇到一个很是棘手的问题,监控系统DPA发现某个自定义标量函数被调用的次数非常高,高到一个离谱的程度.然后在Troubleshooting这个问题的时候,确实遇到了一些问题让我很是纠结,下文是解决 ...

随机推荐

  1. HDOJ2955 0/1背包的价值和重量

    [hdoj2955] 1.概率问题: 计算逃跑率,但是要变成相×的 2.背包处理问题 然后因为率不能作为那个重量,所以价值作为重量,求一个在每个价值下的最大的逃跑率,然后在给定的逃跑率下面,来一个su ...

  2. 【杂谈】5G有啥用?跟咱有关系么?关注那玩意儿干啥?

    用处大了 有啥用? 云计算啊,你看看你电脑都卡成啥了? 既然5G速度赶上本地读取,那就相当于把硬盘放云端没问题了.那么,看看自己硬盘里都有啥,5G的用处或许就能一点点浮现出来了. ——请不要急着打开一 ...

  3. java中多线程的两种创建方式

    一丶继承Thread类实现多线程 第一步:继承Thread类第二步:重写run()方法第三步:创建继承了Thread类的对象 , 调用start()方法启动. //线程创建方式一 : /* 第一步:继 ...

  4. Github配置SSH连接

    安装git.exe,打开Git Bash 1.检查是否已经有SSH Key. $cd /.ssh 2.生成一个新的SSH. $ ssh-keygen -t rsa -C "email@git ...

  5. IE css hack整理

    CSS hack由于不同的浏览器,比如Internet Explorer 6,Internet Explorer 7,Mozillafirefox等,对CSS的解析认识不一样,因此会导致生成的页面效果 ...

  6. fzu Problem 2198 快来快来数一数 (快速幂+优化)

    题目链接: Problem  2198  快来快来数一数 题目描述: 给出n个六边形排成一排,a[i]代表i个六边形能组成的生成树个数,设定s[i]等于a[1]+a[2]+a[3]+....+a[i- ...

  7. One hundred layer HDU - 4374

    One hundred layer HDU - 4374 $sum[i][j][k]$表示第i层第j到k列的和 $ans[i][j]$表示第i层最终停留在第j列的最大值,那么显然$ans[i][j]= ...

  8. Spark MLlib编程API入门系列之特征选择之卡方特征选择(ChiSqSelector)

    不多说,直接上干货! 特征选择里,常见的有:VectorSlicer(向量选择) RFormula(R模型公式) ChiSqSelector(卡方特征选择). ChiSqSelector用于使用卡方检 ...

  9. poj2455Secret Milking Machine(二分+最大流)

    链接 二分距离,小于当前距离的边容量+1,使最后流>=t 注意 会有重边 #include <iostream> #include<cstdio> #include< ...

  10. AJPFX关于Set接口学习笔记及总结

    Set接口中的方法和Collection中方法一致的.Set接口取出方式只有一种,迭代器. |--HashSet:底层数据结构是哈希表,线程是不同步的.无序,高效: HashSet集合保证元素唯一性: ...