Hi thereI have a SourceBatchItems table that is used for pumping data from csv text file. The data is load per SourceBatchID with potentially 1.5 million records and this table will used for transformation at later stage.The SourceBatchItems table schemas as follow:RowID BIGINT NOT NULL IDENTITYColumn1 varchar(4) NULLColumn2 varchar(8) NULLColumn3 varchar(64) NULLColumn4 varchar(16) NULLColumn5 varchar(16) NULLColumn6 varchar(16) NULLColumn7 varchar(32) NULLColumn8 varchar(64) NULLColumn9 varchar(16) NULLColumn10 varchar(16) NULLColumn11 varchar(128) NULLColumn12 varchar(16) NULLColumn13 varchar(16) NULLColumn14 varchar(16) NULLColumn15 varchar(32) NULLColumn16 varchar(16) NULLColumn17 varchar(16) NULLColumn18 varchar(64) NULLSourceBatchID INTCreatedUTCTimeStamp DATETIME NULLThe query in stored procedure that I run to manipulate for the transformation is:SELECT CAST(RTRIM(LTRIM(Column4) AS VARCHAR(32) AS AccountNo,CAST(RTRIM(LTRIM(COlumn6)) AS VARCHAR(32)) AS ProductDescription2FROM SourceBatchItems (NOLOCK)WHERE RTRIM(LTRIM(COlumn7)) = '1' AND RTRIM(LTRIM(Column8)) = 'A' AND RTRIM(LTRIM(COlumn9)) = '' AND RTRIM(LTRIM(Column9)) = 'D'AND (LTRIM(RTRIM(Column11)) <> 'SUMMARY OF CHARGES'AND (LTRIM(RTRIM(Column11)) <> 'EXC GST'AND SourceBatchID = @SourceBatchID
Basically, I get from the SOurceBatchItems per SourceBatchID and Column7, Column8, Column9, Column10 considered as Code while the Column11 is kinda description. All queries for manipulation/transformation is similar but more to STRING manipulation on Column11.Now for the indexing, originally this table has PRIMARY KEY so I drop this cause I don't see the usefull of this. Instead of I am thinking do this:CREATE CLUSTERED INDEX IX_SourceBatchItems_1ON SourceBatchItems(SourceBatchID, Column7, Column8, Column9, Column10)WITH (FILL FACTOR = 100, PAD_INDEX = ON)
What do you think? Do I need to put Column11 as well? BTW this index is below 900 bytes so I can include this COlumn11 potentially.How do I test this though to see this?I am apprecited your comment.