大家好,因为我已经在这里发布了:
我在执行我的 SSIS 包时遇到了一些问题,实际上它们需要大量时间。由于很多限制,我正在尝试一对一解决!我从查询开始,提取 720 000 行需要三个多小时:
Select
--11 fields from tbl1
Tbl1.field1 As field1,
….
.
.
Tbl1.field11 As field11,
CASE WHEN (dbo.tbl1.field11 = 'J')
THEN N'Batch' ELSE dbo.tbl1.field11 END AS creation_oprid, CONVERT(date, tbl1.date1)
AS creation_date, CONVERT(date, tbl1.date2) AS update_date,
CASE WHEN (dbo.tbl1.field12 = 'J')
THEN N'Batch' ELSE dbo.tbl1.field12 END AS update_oprid,
tbl1.id,
--3 fields from tbl2
Tbl2.field1 As field1,
….
.
.
Tbl2.field3 As field3,
Tbl3.field1 As field1,
Tbl4.field1 As field1,
Tbl3_2.field1 As field1,
--30 fields from tbl5
Tbl5.field1 As field1,
….
.
.
Tbl5.field30 As field30,
--7 fields from tbl6
Tbl6.field1 As field1,
….
.
.
Tbl6.field7 As field7,
--5 fields from tbl7
Tbl7.field1 As field1,
….
.
.
Tbl8.field5 As field5,
--7 fields from tbl8
Tbl8.field1 As field1,
….
.
.
Tbl8.field7 As field7,
--
---6 conditions from the same table and the same field and 6 conditions with AND
CASE WHEN tbl9.field1 = N'Value1' THEN tbl9.field2 END AS XXX1,
CASE WHEN tbl9.field1 = N'Value1' THEN tbl9.field2 AND
Tbl9.field3= 'SAMEValue' THEN N'Batch' ELSE Tbl9.field3 END AS YYY1,
.
.
CASE WHEN tbl9.field1 = N'Value6' THEN tbl9.field2 END AS XXX6,
CASE WHEN tbl9.field1 = N'Value6' THEN tbl9.field2 AND
Tbl9.field3= 'SAMEValue' THEN N'Batch' ELSE Tbl9.field3 END AS YYY6,
Tbl3_4.field1 As field1,
Dbo.tbl10.field1 As field1,
Dbo.tbl10_1.field1 As field1,
CASE WHEN dbo.tbl8.TYPE_ID = 9 THEN N'Y' WHEN dbo. dbo.tbl8.TYPE_ID = 10 THEN N'N' END AS
flag,
CASE WHEN dbo.tbl11.field_ID IS NOT NULL
THEN ('O_' + dbo.tbl11.field_ID) END AS field_ID,
CASE WHEN dbo.tbl12.field_ID IS NOT NULL THEN ('L_' + dbo.tbl12.field_ID) END AS field_ID
,ROW_NUMBER() OVER (ORDER BY id,dbo.tbl8.FIELDID,dbo.tbl8.Field2ID) AS RowNumber
FROM
dbo.tbl1
INNER JOIN dbo.tbl8
ON tbl1.field_ID = Tbl8.contact_field_ID
LEFT OUTER JOIN dbo.tbl12
ON dbo.TBL1.PERSON_ID = dbo.tbl12.FIELD_ID_CONTACT
LEFT OUTER JOIN dbo.PS_RSF_OPP_CONTACT
ON dbo.TBL1.PERSON_ID = dbo.tbl11.FIELD_ID_CONTACT
LEFT OUTER JOIN dbo.tbl3 AS tbl3_4
ON TBL1.COMM_METHOD = tbl3_4.FIELDVALUE AND (FIELDNAME = N'VALUE') AND (EFF_STATUS = N'A')
LEFT OUTER JOIN dbo.tbl9
ON TBL1.FIELD_ID = tbl9.FIELD_ID
LEFT OUTER JOIN dbo.tbl5
ON TBL1.FIELD_ID = tbl5.FIELD_ID
LEFT OUTER JOIN dbo.tbl7
ON TBL1.FIELD_ID = tbl7.FIELD_ID
LEFT OUTER JOIN tbl6
ON TBL1.FIELD_ID = tbl6.FIELD_ID
LEFT OUTER JOIN dbo.tbl10 AS tbl10_1
RIGHT OUTER JOIN dbo.tbl13
ON tbl10_1.CM_PURPOSE_TYPE_ID = dbo.tbl13.CM_PURPOSE_TYPE_ID
ON TBL1.FIELD_ID = tbl13.FIELD_ID
LEFT OUTER JOIN dbo.tbl10
RIGHT OUTER JOIN dbo.tbl14
ON dbo.tbl10.CM_PURPOSE_TYPE_ID = dbo.tbl14.CM_PURPOSE_TYPE_ID
ON TBL1.FIELD_ID = tbl14.FIELD_ID
LEFT OUTER JOIN dbo.tbl3 AS tbl3_2
ON TBL1.PRSN_TYPE = tbl3_2.FIELDVALUE AND (tbl3_2.FIELDNAME = N'PRSN_TYPE')
AND (tbl3_2.EFF_STATUS = N'A')
LEFT OUTER JOIN dbo.tbl4
ON TBL1.FIELD_CD = TBL4.FIELD_CD
LEFT OUTER JOIN dbo.tbl3 AS tbl3
ON TBL1.Field_CD = tbl3.FIELDVALUE AND (tbl3.FIELDNAME = N' LANG')
AND (tbl3.EFF_STATUS = N'A')
LEFT OUTER JOIN dbo.tbl2 AS tbl2
ON TBL1.FIELD_ID = tbl2.FIELD_ID AND (tbl2.PRIMARY_IND = 'Y')
ORDER BY dbo.TBL1.PERSON_ID
谢谢您的帮助