<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Partially refreshing(Insert/Update/delete) records of the fact table with a partial reload in Connectivity &amp; Data Prep</title>
    <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516156#M14852</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm working on a data model&amp;nbsp;for the logistics sector with a large fact table where the items that are currently processed need to be updated frequently (Inserted, updated, and deleted records), while keeping the items which are finished in the fact table for historical KPIs. Which would be the fastest way to do so? Here is my MWE, where I generate a fact table with 20,000,000 records and update today’s 20,000 records. This script runs and achieves the goal. I get around 4 seconds for a partial reload and around 20 seconds for a full reload. Although this is not bad, it ‘feels’ strange with a noconcatenated tmp-table. Would be a better approach? Especially if I do not care about the full load duration, I just want to minimize the duration of the partial reload. Is there an option to enforce Indexing of %Date to speed up the filtering, or an incremental load technique to just update the records where PartialReload = true()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is My Script and the App&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;let vStartTime = Now();&lt;/DIV&gt;
&lt;DIV&gt;let vSize = 20000000;&lt;/DIV&gt;
&lt;DIV&gt;let vRowsPerDate = $(vSize)/1000;&lt;/DIV&gt;
&lt;DIV&gt;let vPartialReload = IsPartialReload();&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Full_Load_Facts:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;$(vSize) - RecNo() + 1 as ID,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; date(today() - ceil(RecNo() / $(vRowsPerDate))) as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; 1+ Floor(Rand()*100) as Value,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + Floor(Rand() * 26)) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; false() as PartialReload&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(vSize);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Dims:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + RecNo() - 1) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + RecNo() - 1) &amp;amp; Chr(Ord('B') + RecNo() - 1) &amp;amp; Chr(Ord('C') + RecNo() - 1) as DimLabel&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE 26;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Calendar:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; date(today() - RecNo() +1) as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Week(date(today() - RecNo())) as Week,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; WeekDay(date(today() - RecNo())) as WeekDay,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Year(date(today() - RecNo())) as Year,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Month(date(today() - RecNo())) as Month,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MonthName(date(today() - RecNo())) as MonthName&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(vSize)/$(vRowsPerDate) + 1;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;IF IsPartialReload() THEN&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; let vStartTime = Now();&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; tmp:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; NoConcatenate&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; replace only load&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; resident Full_Load_Facts&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; where PartialReload = false();&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; drop table Full_Load_Facts;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; rename table tmp to Full_Load_Facts;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Add only LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $(vSize) + RecNo() as ID,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; today() as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + Floor(Rand()*100) as Value,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Chr(Ord('A') + Floor(Rand()*26)) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; true() as PartialReload&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; AUTOGENERATE $(vRowsPerDate);&lt;/DIV&gt;
&lt;DIV&gt;EndIf;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;let vEndTime = Now();&lt;/DIV&gt;
&lt;DIV&gt;let vReloadDuration = Interval(vEndTime - vStartTime, 's');&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Alex&lt;/P&gt;</description>
    <pubDate>Tue, 29 Apr 2025 17:13:14 GMT</pubDate>
    <dc:creator>AlexanderStraub</dc:creator>
    <dc:date>2025-04-29T17:13:14Z</dc:date>
    <item>
      <title>Partially refreshing(Insert/Update/delete) records of the fact table with a partial reload</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516156#M14852</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm working on a data model&amp;nbsp;for the logistics sector with a large fact table where the items that are currently processed need to be updated frequently (Inserted, updated, and deleted records), while keeping the items which are finished in the fact table for historical KPIs. Which would be the fastest way to do so? Here is my MWE, where I generate a fact table with 20,000,000 records and update today’s 20,000 records. This script runs and achieves the goal. I get around 4 seconds for a partial reload and around 20 seconds for a full reload. Although this is not bad, it ‘feels’ strange with a noconcatenated tmp-table. Would be a better approach? Especially if I do not care about the full load duration, I just want to minimize the duration of the partial reload. Is there an option to enforce Indexing of %Date to speed up the filtering, or an incremental load technique to just update the records where PartialReload = true()?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is My Script and the App&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;let vStartTime = Now();&lt;/DIV&gt;
&lt;DIV&gt;let vSize = 20000000;&lt;/DIV&gt;
&lt;DIV&gt;let vRowsPerDate = $(vSize)/1000;&lt;/DIV&gt;
&lt;DIV&gt;let vPartialReload = IsPartialReload();&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Full_Load_Facts:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;$(vSize) - RecNo() + 1 as ID,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; date(today() - ceil(RecNo() / $(vRowsPerDate))) as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; 1+ Floor(Rand()*100) as Value,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + Floor(Rand() * 26)) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; false() as PartialReload&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(vSize);&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Dims:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + RecNo() - 1) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Chr(Ord('A') + RecNo() - 1) &amp;amp; Chr(Ord('B') + RecNo() - 1) &amp;amp; Chr(Ord('C') + RecNo() - 1) as DimLabel&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE 26;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Calendar:&lt;/DIV&gt;
&lt;DIV&gt;LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; date(today() - RecNo() +1) as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Week(date(today() - RecNo())) as Week,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; WeekDay(date(today() - RecNo())) as WeekDay,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Year(date(today() - RecNo())) as Year,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Month(date(today() - RecNo())) as Month,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; MonthName(date(today() - RecNo())) as MonthName&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;AUTOGENERATE $(vSize)/$(vRowsPerDate) + 1;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;IF IsPartialReload() THEN&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; let vStartTime = Now();&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; tmp:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; NoConcatenate&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; replace only load&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; *&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; resident Full_Load_Facts&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; where PartialReload = false();&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; drop table Full_Load_Facts;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; rename table tmp to Full_Load_Facts;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Add only LOAD&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; $(vSize) + RecNo() as ID,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; today() as %Date,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 1 + Floor(Rand()*100) as Value,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Chr(Ord('A') + Floor(Rand()*26)) as %Dim,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; true() as PartialReload&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; AUTOGENERATE $(vRowsPerDate);&lt;/DIV&gt;
&lt;DIV&gt;EndIf;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;let vEndTime = Now();&lt;/DIV&gt;
&lt;DIV&gt;let vReloadDuration = Interval(vEndTime - vStartTime, 's');&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Tue, 29 Apr 2025 17:13:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516156#M14852</guid>
      <dc:creator>AlexanderStraub</dc:creator>
      <dc:date>2025-04-29T17:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Partially refreshing(Insert/Update/delete) records of the fact table with a partial reload</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516216#M14854</link>
      <description>&lt;P&gt;You could look into the load MERGE functionality in Qlik Sense. It is designed for handling inserts, updates and delete.&lt;/P&gt;&lt;P&gt;See this page for more info:&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/Merge.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefixes/Merge.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Apr 2025 04:05:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516216#M14854</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2025-04-30T04:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Partially refreshing(Insert/Update/delete) records of the fact table with a partial reload</title>
      <link>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516525#M14856</link>
      <description>&lt;P&gt;Hi Vegar,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks, took me a while to understand how this would work with MERGE. So my approach would be this one, which is slightly slower during partial reaload, but the code is more compact and easier to read. Would that be the solution with MERGE which you had in mind?&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let vStartTime = Now();
let vSize = 20000000;
let vRowsPerDate = $(vSize)/1000;
let vPartialReload = IsPartialReload();

Full_Load_Facts:
LOAD
     $(vSize) - RecNo() + 1 						as ID,
    date(today() - ceil(RecNo() / $(vRowsPerDate))) as %Date,
    1+ Floor(Rand()*100) 							as Value,
    Chr(Ord('A') + Floor(Rand() * 26)) 				as %Dim,
    false() 										as PartialReload
AUTOGENERATE $(vSize);

Dims:
LOAD
    Chr(Ord('A') + RecNo() - 1) 															as %Dim,
    Chr(Ord('A') + RecNo() - 1) &amp;amp; Chr(Ord('B') + RecNo() - 1) &amp;amp; Chr(Ord('C') + RecNo() - 1)	as DimLabel
AUTOGENERATE 26;

Calendar:
LOAD
    date(today() - RecNo() +1) 			as %Date,
    Week(date(today() - RecNo())) 		as Week,
    WeekDay(date(today() - RecNo()))	as WeekDay,
    Year(date(today() - RecNo())) 		as Year,
    Month(date(today() - RecNo())) 		as Month,
    MonthName(date(today() - RecNo())) 	as MonthName    
AUTOGENERATE $(vSize)/$(vRowsPerDate) + 1;


Merge On ID
    LOAD
        'Delete' as Operation,
        ID
 resident Full_Load_Facts
    WHERE PartialReload = true();


Add LOAD
$(vSize) + RecNo()                as ID,
today()                           as %Date,
1 + Floor(Rand()*100)             as Value,
Chr(Ord('A') + Floor(Rand()*26))  as %Dim,
true()                            as PartialReload
AUTOGENERATE $(vRowsPerDate);

let vEndTime = Now();
let vReloadDuration = Interval(vEndTime - vStartTime, 's');
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 16:59:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Connectivity-Data-Prep/Partially-refreshing-Insert-Update-delete-records-of-the-fact/m-p/2516525#M14856</guid>
      <dc:creator>AlexanderStraub</dc:creator>
      <dc:date>2025-05-02T16:59:27Z</dc:date>
    </item>
  </channel>
</rss>

