Incremental Load
Incremental Load
Incremental Load
Is sometimes called
Incremental Load Differential Load Delta Load
Incremental Load
Goal: Load only the new or the changed records from the database. The rest should already be available, one way or another.
Incremental Load
Load new data from Database table (slow, but few records) Load old data from QVD file (many records, but fast) Create new QVD file Procedure must be repeated for each table
Different DB-changes
If source allows
1) 2) 3) 4) Append only. (Logfiles) Insert only. (No Update or Delete) Insert and Update. (No Delete) Insert, Update and Delete.
1) Append only
Must be Log file Loads records added in the end of the file
1) Append only
Buffer (Incremental) Load * From LogFile.txt (ansi, txt, delimiter is '\t', embedded labels);
Done!
But it should be renamed to Buffer (Append) Load
2) Insert only
Can be any DB Loads INSERTed records Needs the field ModificationDate
2) Insert only
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)#;
2) Insert only
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD;
2) Insert only
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD;
Almost done
But there is a small chance that a record gets loaded twice
2) Insert only
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)# AND ModificationTime < #$(BeginningThisExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD; STORE QV_Table INTO File.QVD;
Done!
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD WHERE NOT Exists(PrimaryKey); STORE QV_Table INTO File.QVD;
Done!
QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD WHERE NOT EXISTS(PrimaryKey); Inner Join SQL SELECT PrimaryKey FROM DB_TABLE; STORE QV_Table INTO File.QVD;
Final Script
Let ThisExecTime = Now(); QV_Table: SQL SELECT PrimaryKey, X, Y FROM DB_TABLE WHERE ModificationTime >= #$(LastExecTime)# AND ModificationTime < #$(ThisExecTime)#; Concatenate LOAD PrimaryKey, X, Y FROM File.QVD WHERE NOT EXISTS(PrimaryKey); Inner Join SQL SELECT PrimaryKey FROM DB_TABLE; If ScriptErrorCount = 0 then STORE QV_Table INTO File.QVD; Let LastExecTime = ThisExecTime; End If
Summary 1
Summary 2
Incremental Load normally not equivalent to Buffer (Incremental) Load