<?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 Where vs Exists in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226269#M713212</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for taking a look at this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This wasn't the actual problem, just a volume test. It showed, at least in this example, that Exists is way faster when not using any transformations but slower when using them which is totally contra intuitive imo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Aug 2010 22:20:47 GMT</pubDate>
    <dc:creator>danielrozental</dc:creator>
    <dc:date>2010-08-06T22:20:47Z</dc:date>
    <item>
      <title>Where vs Exists</title>
      <link>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226267#M713210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure if this has been covered before in a discussion, sorry if it was.&lt;/P&gt;&lt;P&gt;While I was doing a few high volume tests I ran into what I believe might be an exists clause glitch and I wanted to share it hoping someone at QT will pick it up or at least It might be useful to someone.&lt;/P&gt;&lt;P&gt;I'm using QV9 SR4 (not the latest, I know) and a version of the 10 Million rows application that has 50 Million.&lt;/P&gt;&lt;P&gt;1. First I did a simple load using a Where clause, it took 58 secs to load 945.501 rows.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS&lt;BR /&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; R00.QVD (qvd)&lt;BR /&gt;&lt;STRONG&gt;where&lt;/STRONG&gt; ProductID = 40;&lt;BR /&gt;&lt;STRONG&gt;drop&lt;/STRONG&gt; &lt;STRONG&gt;table&lt;/STRONG&gt; &lt;I&gt;R00;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;2. Then I thought a where exists clause would be much faster, since the load would be optimized, and it was. It took only 4 secs to load the same information as the code above&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;load&lt;/STRONG&gt; 40 &lt;STRONG&gt;as&lt;/STRONG&gt; ProductID &lt;STRONG&gt;autogenerate&lt;/STRONG&gt;(1);&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS&lt;BR /&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; R00.QVD (qvd)&lt;BR /&gt;&lt;STRONG&gt;where Exists&lt;/STRONG&gt;(ProductID);&lt;BR /&gt;&lt;STRONG&gt;drop table&lt;/STRONG&gt; &lt;I&gt;R00;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;So far nothing out of the ordinary.&lt;/P&gt;&lt;P&gt;3. Then I added a transformation, this way neither the simple where nor the where exists clauses will have the benefit of the optimized load.&lt;/P&gt;&lt;P&gt;I only added "Quantity*UnitPrice - Discount &lt;STRONG&gt;as&lt;/STRONG&gt; NetSales". The load took 0.59 secs&lt;/P&gt;&lt;DIV&gt;&lt;I&gt;&lt;/I&gt;&lt;P style="font-style: italic"&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS, Quantity*UnitPrice - Discount &lt;STRONG&gt;as&lt;/STRONG&gt; NetSales&lt;BR /&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; R00.QVD (qvd)&lt;BR /&gt;&lt;STRONG&gt;where&lt;/STRONG&gt; ProductID = 40;&lt;BR /&gt;&lt;STRONG&gt;drop table&lt;/STRONG&gt; R00;&lt;/P&gt;&lt;P&gt;4. Same thing, I added &lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;I&gt;&lt;/I&gt;&lt;DIV style="display: inline !important; "&gt;&lt;I&gt;"Quantity*UnitPrice - Discount&lt;/I&gt; &lt;STRONG&gt;as&lt;/STRONG&gt; NetSales" to the where exists load at it took &lt;STRONG&gt;&lt;I&gt;3 minutes, 38 seconds !!!&lt;/I&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;load&lt;/STRONG&gt; 40 &lt;STRONG&gt;as&lt;/STRONG&gt; ProductID &lt;STRONG&gt;autogenerate&lt;/STRONG&gt;(1);&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS, &lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P style="display: inline !important; font-style: italic"&gt;Quantity*UnitPrice - Discount &lt;STRONG&gt;as&lt;/STRONG&gt; NetSale&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; R00.QVD (qvd)&lt;BR /&gt;&lt;STRONG&gt;where Exists&lt;/STRONG&gt;(ProductID);&lt;BR /&gt;&lt;STRONG&gt;drop tabl&lt;/STRONG&gt;e &lt;I&gt;R00;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;5. I tried doing it in two steps, first the optimized where exists load, and then the transformation. It took &lt;STRONG&gt;16 secs&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;load&lt;/STRONG&gt; 40 &lt;STRONG&gt;as&lt;/STRONG&gt; ProductID &lt;STRONG&gt;autogenerate&lt;/STRONG&gt;(1);&lt;/P&gt;&lt;P&gt;R00_Temp:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt; R00.QVD (qvd)&lt;BR /&gt;&lt;STRONG&gt;where Exists&lt;/STRONG&gt;(ProductID);&lt;BR /&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;R00:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;LOAD&lt;/STRONG&gt; ShipperID, OrderDate, CustomerID, Discount, ProductID, Quantity, UnitPrice, sales, COS&lt;I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P style="display: inline !important; font-style: italic"&gt;, Quantity*UnitPrice - Discount &lt;STRONG&gt;as&lt;/STRONG&gt; NetSale&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;STRONG&gt;RESIDENT&lt;/STRONG&gt; R00_Temp&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop tabl&lt;/STRONG&gt;e &lt;I&gt;R00_Temp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;drop tabl&lt;/STRONG&gt;e &lt;I&gt;R00;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully some else might have a view on this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jul 2010 01:40:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226267#M713210</guid>
      <dc:creator>danielrozental</dc:creator>
      <dc:date>2010-07-19T01:40:49Z</dc:date>
    </item>
    <item>
      <title>Where vs Exists</title>
      <link>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226268#M713211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only thing that seems unusual to me in your list is the 3 minutes, 38 seconds for #4. While the calculation will break the optimized load, I wouldn't expect it to be any slower than the where ProductID = 40 version.&lt;/P&gt;&lt;P&gt;And testing with a QVD of my own does not duplicate what you're seeing. I got 24 seconds with the where exists, 25 seconds with the where =. I'm on SR5, but it seems unlikely that they would coincidentally have fixed this between these two very similar versions.&lt;/P&gt;&lt;P&gt;In any case, I'd never code your version #4 causing the problem. Where = is much easier, so unless you ARE going to get an optimized load, I'd be using the where = version. So it doesn't seem like a practical problem to me.&lt;/P&gt;&lt;P&gt;In case it makes any difference, I code this sort of thing like this to avoid the temp table:&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;R00:&lt;BR /&gt;load 40 as ProductID&lt;BR /&gt;autogenerate(1);&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;INNER JOIN (R00)&lt;BR /&gt;LOAD ShipperID,&lt;BR /&gt; OrderDate,&lt;BR /&gt; CustomerID,&lt;BR /&gt; Discount,&lt;BR /&gt; ProductID,&lt;BR /&gt; Quantity,&lt;BR /&gt; UnitPrice,&lt;BR /&gt; sales,&lt;BR /&gt; COS&lt;BR /&gt;FROM R00.QVD (qvd)&lt;BR /&gt;where exists(ProductID);&lt;/P&gt;&lt;P style="padding-left:30px;"&gt;LEFT JOIN (R00)&lt;BR /&gt;LOAD *, Quantity*UnitPrice - Discount as NetSales&lt;BR /&gt;RESIDENT R00;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Aug 2010 22:07:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226268#M713211</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2010-08-06T22:07:16Z</dc:date>
    </item>
    <item>
      <title>Where vs Exists</title>
      <link>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226269#M713212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for taking a look at this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This wasn't the actual problem, just a volume test. It showed, at least in this example, that Exists is way faster when not using any transformations but slower when using them which is totally contra intuitive imo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Aug 2010 22:20:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Where-vs-Exists/m-p/226269#M713212</guid>
      <dc:creator>danielrozental</dc:creator>
      <dc:date>2010-08-06T22:20:47Z</dc:date>
    </item>
  </channel>
</rss>

