我有以下观点:
use strict;
use warnings;
my $str=" a, b, c>d:e, f, g ";
$str =~ s/\s+//g; # remove all occurrences of 1 or more spaces
my @columns = split(/,/, $str);
print join(',', @columns), "\n";
基表具有以下信息:
如果我尝试在sql server中执行此视图,则需要大约16-20秒才能完成150.000行(现在,将来会增加)。
如何提高视图效果?
我读到了索引视图,但基表不是静态的,因此在创建新用户/机会/任何时候放置必须更新的索引似乎很危险。此外,我无法修改基表,只需阅读它们。
感谢您提供的任何帮助。
由于
答案 0 :(得分:0)
您可以尝试在没有子查询的情况下构建视图:
SELECT [OPER_ID] as IdOpportunity,
CASE WHEN LEN(partner_no) = 10 THEN u1.shortname ELSE partner_no END as ShortName,
o.CASETITLE as OpportunityDesc,
o.CLIENTSOLICID as IdClientSolic,
o.CLIENTSOLICNAME as ClientSolicDesc,
u.shortname as IdSocResp,
u.NAME + ' ' + u.Lastname_1 + ' ' + u.lastname_2 as SocRespName,
o.GROUPADMID as IdGroupAdm,
o.GROUPADMDESC as GroupAdmDesc,
o.OFFICEID as IdOffice,
o.OFFICEDESCRIPTION as OfficeDesc,
o.AREAID as IdArea,
o.AREADESC as AreaDesc,
o.TYPEOPERATION as OperationType
FROM [SAP].[dbo].[ZTB_OPPMATT_BP]
INNER JOIN [SAP].dbo.tb_opportunity_list_prod o
ON o.OPPORTUNITYID = [oper_id]
INNER JOIN [SAP].[dbo].[tb_user_list_prod] u
ON u.empid = SUBSTRING(o.[LEADINGID], 3, LEN(o.[LEADINGID]))
LEFT JOIN [SAP].dbo.tb_user_list_prod u1
ON u1.empid = right(partner_no, 8) AND year(u1.enddate) = 9999
WHERE partner_fct IN ('ZCREA','Z6','Z2','ZLEAD','00000014','00000032')
AND PROCESS_TYPE IN ('ZOSE','ZOPB','ZOPP')
AND (CASE WHEN LEN(partner_no) = 10 THEN u1.shortname ELSE partner_no END) NOT IN ('','-')