当我执行以下查询时,执行时间超过2分钟,如何提高数据透视表查询的性能或任何替代方案。这是我写的查询:
SELECT RBG AS 'RBG/SBG NAME',
[PROJ] AS 'TOTAL NO OF PROJECT',
[CONT] AS 'TOTAL NO OF CONTRACT',
[CONTV] AS 'NO OF CONTRATORS',
[BOQV] AS 'NO_OF_BOQ_CNT',
[BILLV] AS 'NO_OF_BILL_CNT',
[BILLAPPV] AS 'NO_OF_APP_BILL_CNT',
[CONTC] AS 'NO OF CONSULTSNT',
[BOQC] AS 'NO_OF_BOQ_CUN',
[BILLC] AS 'NO_OF_BILL_CUN',
[BILLAPPC] AS 'NO_OF_APP_BILL_CUN',
[BOQ] AS 'TOTAL NO OF BOQ UPLOADED',
[BILL] AS 'CONTRACTOR LEVEL',
[BILLAPP] AS 'BILL APPROVED',
([BILL]+[BILLAPP]) AS 'TOTAL NO OF BILL'
INTO TableB
FROM
(SELECT RBG,
PROJ_TYPE,
ISNULL(PROJECT_CODE,0) AS PROJECT_CODE
FROM TableA) S PIVOT(COUNT(PROJECT_CODE)
FOR PROJ_TYPE IN ([PROJ],[CONT],[CONTV],[BOQV],[BILLV],[BILLAPPV],[CONTC],[BOQC],[BILLC],[BILLAPPC],[BOQ],[BILL],[BILLAPP])) P