<?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 Big table of users (efficient sql select) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978599#M334245</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a User table with almost 500 million records and I have been including it partially in the model like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left Keep (Fact)&lt;/P&gt;&lt;P&gt;load * ;&lt;/P&gt;&lt;P&gt;sql select * from Users;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Both tables join on user ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, this approach looks into the entire 500M record table, before it joins with the users contained in the fact table, which takes quite a while. Is there a better approach? Is there a way to SQL Select with a where clause, using the distinct users from the Fact table, for example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Nuno &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Nov 2015 15:27:27 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-11-11T15:27:27Z</dc:date>
    <item>
      <title>Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978599#M334245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a User table with almost 500 million records and I have been including it partially in the model like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;left Keep (Fact)&lt;/P&gt;&lt;P&gt;load * ;&lt;/P&gt;&lt;P&gt;sql select * from Users;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(Both tables join on user ID)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, this approach looks into the entire 500M record table, before it joins with the users contained in the fact table, which takes quite a while. Is there a better approach? Is there a way to SQL Select with a where clause, using the distinct users from the Fact table, for example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;Nuno &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:27:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978599#M334245</guid>
      <dc:creator />
      <dc:date>2015-11-11T15:27:27Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978600#M334246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can store the distinct list of user ID in a variable and use that variable in your SQL Where clause. I have done something similar before, will check if I can get hold of that example.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:29:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978600#M334246</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-11-11T15:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978601#M334247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does your Fact table exist in SQL outside of QlikView without a great deal of QVS load logic? If so, perhaps just&lt;/P&gt;&lt;P&gt;SELECT user.* FROM user INNER JOIN fact ON user.userid = fact.userid;&lt;/P&gt;&lt;P&gt;Let the DBMS do the heavy lifting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:36:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978601#M334247</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-11-11T15:36:10Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978602#M334248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you need all fields from the Users table?&lt;/P&gt;&lt;P&gt;Select * can be slower than selecting just the fields you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also consider using a mapping table and applymap rather than joining the data.&lt;/P&gt;&lt;P&gt;It can be quicker to create and apply several mapping tables rather than joining.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 15:42:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978602#M334248</guid>
      <dc:creator>Colin-Albert</dc:creator>
      <dc:date>2015-11-11T15:42:48Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978603#M334249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That seems like the way I want to go. If you find a good example, please let me know.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nuno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:01:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978603#M334249</guid>
      <dc:creator />
      <dc:date>2015-11-13T10:01:37Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978604#M334250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you join in the database (SQL select .....)&amp;nbsp; the fact table and the users table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:09:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978604#M334250</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2015-11-13T10:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978605#M334251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the fact table is created within qlikview. Getting it to sql again (or creating it in sql to begin with) would beat the purpose of what I am trying to achieve.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Nuno&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:45:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978605#M334251</guid>
      <dc:creator />
      <dc:date>2015-11-13T10:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978606#M334252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How many distinct User-IDs do you have in your fact table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:51:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978606#M334252</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-11-13T10:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978607#M334253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Around 200,000.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 10:55:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978607#M334253</guid>
      <dc:creator />
      <dc:date>2015-11-13T10:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978608#M334254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only way I can see that is really efficient and still not very complicated is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1) Create a table in your DB called FACT_USERID having one column UserID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Make sure that you have indexes on the user id columns in the involved tables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2) Load Script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FACT_USERID:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD DISTINCT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UserID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RESIDENT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FACT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; UserID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STORE FACT_USERID INTO FACT_USERID.CSV (txt);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DROP TABLE FACT_USERID;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; EXECUTE cmd.exe /c cmd-file-to-execute-import-of-CSV-into-the-DB.cmd FACT_USERID.CSV;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // all popular SQL databases has some sort of command-line import tool to retrieve txt/csv-files ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LEFT KEEP (FACT)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LOAD * ;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SQL&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SELECT&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; *&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Users&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHERE EXISTS( SELECT USER_ID FROM FACT_USERID);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 11:19:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978608#M334254</guid>
      <dc:creator>petter</dc:creator>
      <dc:date>2015-11-13T11:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Big table of users (efficient sql select)</title>
      <link>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978609#M334255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can build a dynamic sql where condition&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;T: &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Load&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Pick(Ceil(6*Rand1),'a','b','c','d','e','f') as User,&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt; Round(1000*Rand()*Rand()*Rand1) as Expression1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Load&amp;nbsp; Rand() as Rand1, IterNo() as TransLineID, RecNo() as TransID&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Autogenerate 1000&amp;nbsp; While Rand()&amp;lt;=0.5 or IterNo()=1;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;LOAD chr(39) &amp;amp; Concat( DISTINCT User , chr(39) &amp;amp; ',' &amp;amp; chr(39)) &amp;amp; chr(39) AS UserList&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Resident T;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;LET vUsers = Peek('UserList');&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;trace $(vUsers);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then use in SQL&lt;/P&gt;&lt;P&gt;&lt;EM style="font-size: 10pt; line-height: 1.5em;"&gt;SQL select *&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;from Users&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;WHERE User IN ($(&lt;/EM&gt;&lt;STRONG&gt;vUsers &lt;/STRONG&gt;&lt;EM&gt;));&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;for 200k distinct users I think you can't build an efficient where clause;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;example in Oracle a condition &lt;EM style="font-size: 10pt; line-height: 1.5em;"&gt;where user in (user1, user2, ....) &lt;/EM&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;will works only for 1000 users&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;You can try with an OR instead of IN&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;where (user = 'user1' or user = 'user2' ...............)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Maybe an option to load all the users in Qlik with an incremental load?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Nov 2015 11:36:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Big-table-of-users-efficient-sql-select/m-p/978609#M334255</guid>
      <dc:creator>maxgro</dc:creator>
      <dc:date>2015-11-13T11:36:28Z</dc:date>
    </item>
  </channel>
</rss>

