合併報表優化記錄

2021-06-06 06:09:44 字數 4165 閱讀 7541

這是早期的合併報表優化記錄,內容不多,保留下來備查。

一.查詢源報表是否存在

select 1 where exists (select * from t_csl_cslreport where fsourcerptid = '4583062d-010a-1000-e002-63bbc0a8ef02b712ea2c')

未優化前:

執行成本:0.396

reads:2139

duration:10

給t_csl_cslreport的fsourcerptid增加索引後:

執行成本:0.00641

reads:43

duration:0

增加索引後提高了50倍

create index ix_csl_rpt_srcrpt on t_csl_cslreport(fsourcerptid);

二.專案取數

select sum(t_csl_itemdataentry003.f670) "zj17001"

from t_csl_itemdataentry itemdatabd

inner join t_csl_itemdata itemdatahd on itemdatabd.fitemdataid = itemdatahd.fid

left outer join t_csl_rptreceived received on received.freportid = itemdatahd.freportid

left outer join t_csl_itemdataentry003 on itemdatabd.fid = t_csl_itemdataentry003.fid

left outer join t_org_tree orgbound on received.forgtreeid = orgbound.fid

left outer join t_org_baseunit company on itemdatahd.fcompanyid = company.fid

left outer join t_bd_currency cur on itemdatahd.fcurrencyid = cur.fid

left outer join t_bd_currency tgtcur on itemdatahd.ftargetcurrencyid = tgtcur.fid

where ((1 = 1 and (orgbound.fnumber = '005' or (orgbound.fnumber is null)))

and (((((company.fnumber in ('0300100800')

and tgtcur.fnumber = 'bb01')

and itemdatahd.fperiodtype = 1)

and itemdatabd.fyear = 2006)

and itemdatabd.fperiod = 94)

and ((itemdatahd.fdatasource in (1, 7)

and itemdatabd.fdataelement = 4)

and itemdatabd.fvaluetype = 1)))

未優化前:

成本:0.390

reads:920

duration:50

給t_csl_itemdataentry的增加索引(fvaluetype,fyear,fperiod,fdataelement)後:

成本:0.0650

reads:494

duration:40

效率提高一倍,提公升空間不是太大

create index ix_csl_i***e_1 on

t_csl_itemdataentry(fvaluetype,fyear,fperiod,fdataelement);

三. select top 100 "cslreport".fid "id", "orgunit".fname_l2 "orgunit.name", "cslreport".fname "name", "currency".fname_l2 "currency.name",

"sourcecurrency".fname_l2 "sourcecurrency.name", "cslreport".fsourcetype "sourcetype", "cslreport".fperiodtype "periodtype",

"cslreport".fyear "year", "cslreport".fperiod "period", "cslreport".fauditedstatus "auditedstatus",

"cslreport".fcommittedstatus "committedstatus", "cslreport".fcheckedstatus "checkedstatus", "currency".fid "currency.id",

"cslreport".freportdate "reportdate", "template".fid "template.id", "orgunit".fid "orgunit.id",

"template".ftemplatetype "template.templatetype", "tree".fid "tree.id", "cslreport".fconvertstatus "convertstatus",

"cslreport".fadjuststatus "adjuststatus", "structure".flongnumber "structure.longnumber", "parentstructure".fid "parentstructure.id"

from t_csl_cslreport "cslreport"

inner join t_org_baseunit "orgunit" on "cslreport".forgunitid = "orgunit".fid

inner join t_bd_currency "currency" on "cslreport".fcurrencyid = "currency".fid

inner join t_bd_currency "sourcecurrency" on "cslreport".fsourcecurrencyid = "sourcecurrency".fid

inner join t_rpt_template "template" on "cslreport".ftemplateid = "template".fid

inner join t_org_structure "structure" on "orgunit".fid = "structure".funitid

inner join t_org_tree "tree" on "structure".ftreeid = "tree".fid

inner join t_org_structure "parentstructure" on "structure".fparentid = "parentstructure".fid

where ((("cslreport".fsourcetype not in (4, 6) and ("cslreport".fcommittedstatus <> 1))

and "cslreport".fadjuststatus = 0) and (((("cslreport".fperiodtype = 3 and "cslreport".fyear = 2006)

and "cslreport".fperiod = 3) and "tree".fid = 'a2bf23e7-0108-1000-e000-d469c0a8ef024f2827fd')

and ("parentstructure".fid = '0aa070b0-0109-1000-e002-1fe4c0a8ef0232b85c74'

or "structure".flongnumber = '007001!00700103!00700103015')))

成本:1.21

reads:3773

duration:950

給t_csl_cslreport新增索引(fadjuststatus,fyear,fperiod,fsourcetype)後:

成本:0.340

reads:2294

duration:60

合併報表專案取數說明

合併報表為了節省磁碟空間,服務端對專案資料儲存採用了橫表的方式,取數上有些複雜,特說明和示例如下 比如要取2006年8月份 月報 幣別編碼為 001 的人民幣 公司編碼為 c01 的個別表資產負債表中,編碼為 1001 的專案的本期發生數。and b.fnumber 1001 其中a.ftablen...

集團報表合併系統

美德軟體集團報表管理系統應用價值 一 統一管理平台,資料實時傳輸,隨時檢視 美德集團報表系統採用先進的客戶端 伺服器應用模式,利用微軟公司的資料庫平台 ms sql server 將所有資料彙總至伺服器統一儲存 集中管理,所有資料報括財務資料 業務資料 報表資料等。所有分支機構的資料都統一上傳至這個...

報表執行時的報表合併

activereports能夠實現在報表執行時合併報表,即在使用activereports的設計器建立了好幾個不同的報表後,通過幾行 進一步進行合併,作為乙個報表檔案在報表瀏覽器中預覽處理。需要在建立的每個報表中使用addrange方法新增pagescollection就可以了。所得的 report...