<?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 Loading with FirstSortedValue caused memory error/slow down in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Loading-with-FirstSortedValue-caused-memory-error-slow-down/m-p/332113#M706697</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following code caused an out of memory error on QV8.5, and caused a load to chug for over 30 minutes on QV10 when faced with 9 million records:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(LabStaffID, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabStaffID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(max(ReportDate)) as LabResultDate,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(ResultValue, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabResultValue,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(LabResultID, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabResultID&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;FROM $(vQVDPath)\iClinicalsLab.qvd (qvd)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;GROUP BY PatientID, LabComponentName, LOINCID;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I was looking to get the most recent lab result for each type of lab for each patient.&amp;nbsp; I ended up rewriting this to break it up which yielded almost the same results (it does the group by to just get the most recent date, then inner joins it to the rest of the laboratory values):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;LabTEMP:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabStaffID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(ReportDate) as LabResultDate,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResultValue as LabResultValue,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabResultID&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;FROM $(vQVDPath)\iClinicalsLab.qvd (qvd);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;MAXTEMP:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(max(LabResultDate)) as LabResultDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;RESIDENT LabTEMP&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;GROUP BY PatientID, LabComponentName, LOINCID;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;INNER JOIN ('LabTEMP') LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabResultDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;RESIDENT MAXTEMP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;DROP TABLE MAXTEMP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But the whole process got me thinking about load times and GROUP BY clauses.&amp;nbsp; I've fixed the issue while only guessing at the root of the problem.&amp;nbsp; Can anyone help me understand this?&amp;nbsp; I suspect it was the number of FIRSTSORTEDVALUEs within the single load that caused the problem.&amp;nbsp; Is that unique to FIRSTSORTEDVALUE, or would I run into this problem with any aggregate function?&amp;nbsp; Is it the number of aggregate functions that made it so unhappy? I haven't seen any of my other code choke like it did on this, but there's pressure to make these documents load as fast as possible, and I want to eliminate any obvious slow-downs.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;When I have more time, I'll play with some of the code.&amp;nbsp; But I figured I'd float the question out there, in case someone with more experience would know off the top of their head.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 01 Mar 2012 17:13:04 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-03-01T17:13:04Z</dc:date>
    <item>
      <title>Loading with FirstSortedValue caused memory error/slow down</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-with-FirstSortedValue-caused-memory-error-slow-down/m-p/332113#M706697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following code caused an out of memory error on QV8.5, and caused a load to chug for over 30 minutes on QV10 when faced with 9 million records:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(LabStaffID, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabStaffID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(max(ReportDate)) as LabResultDate,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(ResultValue, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabResultValue,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FIRSTSORTEDVALUE(LabResultID, -(ReportDate &amp;amp; num(mod(LabResultID,10000), '0000'))) as LabResultID&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;FROM $(vQVDPath)\iClinicalsLab.qvd (qvd)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;GROUP BY PatientID, LabComponentName, LOINCID;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I was looking to get the most recent lab result for each type of lab for each patient.&amp;nbsp; I ended up rewriting this to break it up which yielded almost the same results (it does the group by to just get the most recent date, then inner joins it to the rest of the laboratory values):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;LabTEMP:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabStaffID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(ReportDate) as LabResultDate,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ResultValue as LabResultValue,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabResultID&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;FROM $(vQVDPath)\iClinicalsLab.qvd (qvd);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;MAXTEMP:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;NOCONCATENATE LOAD &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; date(max(LabResultDate)) as LabResultDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;RESIDENT LabTEMP&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;GROUP BY PatientID, LabComponentName, LOINCID;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;INNER JOIN ('LabTEMP') LOAD&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PatientID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabComponentName,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOINCID,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LabResultDate&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;RESIDENT MAXTEMP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-size: 8pt;"&gt;DROP TABLE MAXTEMP;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;But the whole process got me thinking about load times and GROUP BY clauses.&amp;nbsp; I've fixed the issue while only guessing at the root of the problem.&amp;nbsp; Can anyone help me understand this?&amp;nbsp; I suspect it was the number of FIRSTSORTEDVALUEs within the single load that caused the problem.&amp;nbsp; Is that unique to FIRSTSORTEDVALUE, or would I run into this problem with any aggregate function?&amp;nbsp; Is it the number of aggregate functions that made it so unhappy? I haven't seen any of my other code choke like it did on this, but there's pressure to make these documents load as fast as possible, and I want to eliminate any obvious slow-downs.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;When I have more time, I'll play with some of the code.&amp;nbsp; But I figured I'd float the question out there, in case someone with more experience would know off the top of their head.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Thanks.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Mar 2012 17:13:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-with-FirstSortedValue-caused-memory-error-slow-down/m-p/332113#M706697</guid>
      <dc:creator />
      <dc:date>2012-03-01T17:13:04Z</dc:date>
    </item>
    <item>
      <title>Loading with FirstSortedValue caused memory error/slow down</title>
      <link>https://community.qlik.com/t5/QlikView/Loading-with-FirstSortedValue-caused-memory-error-slow-down/m-p/332114#M706698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shurley,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am experiencing the same thing. It might be a threading issue related to aggregate functions:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.qlik.com/thread/50589"&gt;http://community.qlik.com/thread/50589&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But not sure how to get around it. This post mentions that the DISTINCT clause causes aggregate functions to become sinlge-threaded, but I am not using DISTINCT and neither are you, so I don't know...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 May 2012 14:56:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Loading-with-FirstSortedValue-caused-memory-error-slow-down/m-p/332114#M706698</guid>
      <dc:creator />
      <dc:date>2012-05-04T14:56:47Z</dc:date>
    </item>
  </channel>
</rss>

