<?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 Re: Does the speed of a query decrease with the number of indexes? in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479800#M14982</link>
    <description>&lt;P&gt;There is no database index used in your procedure. My guess is that most of the time is spent reading the whole data table, which might be wasteful, depending on the size of work.cpt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the large table is indexed on proc1, the simple query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;create table cpt_enrolid as&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;select enrolid, proc1, proctype from DWSC1116.CEMR_O_2012_2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where proc1 in (select proc1 from work.cpt);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;might&amp;nbsp;execute faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jul 2018 05:18:27 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-07-20T05:18:27Z</dc:date>
    <item>
      <title>Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479536#M14969</link>
      <description>&lt;P&gt;I looked around for an answer to this question.&amp;nbsp; If I have one index called ENROLID for a very large data set or 10 indexes, one of which is ENROLID, does the query where I select a list of ENROLID values from the data set with one index differ in speed from the same query on the data set with 9 other indexed fields?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do I need to pick and choose my indexes carefully, or should I throw in every possible index I might need?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 15:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479536#M14969</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-19T15:09:56Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479623#M14972</link>
      <description>&lt;P&gt;I would worry more about the cost of creating and maintaining the indexes. Each operation&amp;nbsp;updating, inserting, or&amp;nbsp;deleting a record must&amp;nbsp;also adjust the indexes. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:15:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479623#M14972</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-19T18:15:39Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479633#M14973</link>
      <description>&lt;P&gt;I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;. Also, indexes tend to be more useful on very diverse fields. An index on "Customer Number", where you frequently have to look up individual numbers, can be fantastically useful. An index on "Gender" or "State", where there are a large number of repeated values, tends to be pretty much useless.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479633#M14973</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-19T18:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479636#M14974</link>
      <description>&lt;P&gt;These get updated once per month.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:31:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479636#M14974</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-19T18:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479641#M14975</link>
      <description>&lt;P&gt;I am worried about the query because it is taking hours.&amp;nbsp; I only need one index, so if it would be faster with only one, that is what I want to have.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 18:38:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479641#M14975</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-19T18:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479669#M14978</link>
      <description>&lt;P&gt;In my opinion, if your query is handled by SAS/SQL, the number of indexes is unlikely to be the problem. If this is about a Pass-Through query, then optimization is up to your DBMS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 19:45:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479669#M14978</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-19T19:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479673#M14979</link>
      <description>&lt;P&gt;1. SAS dataset or DBMS table?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. How many rows?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. How many fields and bytes per record?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. How complex is the query?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I very much doubt the existence of the indexes is causing your problems.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jul 2018 19:48:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479673#M14979</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2018-07-19T19:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479692#M14980</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-subject"&gt;Re: Does the speed of a query decrease with the number of indexes?&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-04 lia-quilt-column-right"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="reply-to-stamp"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-message-body lia-tooltip-trigger"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;1. SAS dataset or DBMS table?&lt;/P&gt;&lt;P&gt;I am using the SAS Scalable Performance Data Engine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. How many rows?&lt;/P&gt;&lt;P&gt;Some examples for the files I am accessing.&lt;/P&gt;&lt;P&gt;1,794,533,270&lt;/P&gt;&lt;P&gt;5,080,553,136&lt;/P&gt;&lt;P&gt;1,602,072,953&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Largest 10,125,182,001&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. How many fields and bytes per record?&lt;/P&gt;&lt;P&gt;&amp;nbsp;largest&amp;nbsp;Data&lt;/P&gt;&lt;P&gt;Observations 10125182001&lt;/P&gt;&lt;P&gt;Data Partsize 53477375K&lt;/P&gt;&lt;P&gt;There are three parts, so multiply by three&lt;/P&gt;&lt;P&gt;That looks like 15 bytes per record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4. How complex is the query?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use DS2.&amp;nbsp; Create a hash out of my lookup table which has one field: the index field, then load the larger table and output if index value is found.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;f = h.find();
if (f = 0) then output;

&amp;nbsp;

proc ds2;
data cpt_enrolid (overwrite=yes);
dcl double rc f enrolid;
declare char(7) proc1;
declare char(8) cpt;
dcl package hash h(8, '{select distinct proc1 from work.cpt}');
method init();
rc = h.keys([proc1]);
rc = h.data([proc1]);
rc = h.defineDone();
end;
method run();
set {select enrolid, proc1, proctype from DWSC1116.CEMR_O_2012_2016};
f = h.find();
if (f = 0) then output;
end;
enddata;
run;
quit;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Jul 2018 21:44:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479692#M14980</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-19T21:44:51Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479800#M14982</link>
      <description>&lt;P&gt;There is no database index used in your procedure. My guess is that most of the time is spent reading the whole data table, which might be wasteful, depending on the size of work.cpt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the large table is indexed on proc1, the simple query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;create table cpt_enrolid as&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;select enrolid, proc1, proctype from DWSC1116.CEMR_O_2012_2016&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;where proc1 in (select proc1 from work.cpt);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;might&amp;nbsp;execute faster.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hth.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jul 2018 05:18:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/479800#M14982</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-20T05:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481252#M15013</link>
      <description>&lt;P&gt;I appreciate your suggestion and used it.&amp;nbsp; The speed did increase.&amp;nbsp; However I noticed something odd.&amp;nbsp; When I use a sub query in the where statement as you suggest, the speed is not as fast as when I take your idea one step further and use a simple string instead of the sub query.&amp;nbsp; This is not what I had expected.&amp;nbsp; But I will start using the SAS macro facility to replace the sub query with a text string on my queries.&amp;nbsp; Three minutes vs three hours to get the same&amp;nbsp;243570 observations.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this a SAS bug or am I missing something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;243570 rows and 3 columns.&lt;/PRE&gt;&lt;PRE&gt;1584
1585  proc sql _method;
1586  create table test as
1587  select enrolid, proc1, proctyp from DWSC1116.CEMR_O_2012_2016 where
1588  PROC1 in ('64615')
1589  ;

NOTE: SQL execution methods chosen are:

      sqxcrta
          sqxsrc( DWSC1116.CEMR_O_2012_2016 )

whinit: WHERE (PROC1='64615')
whinit: INDEX PROC1 uses 13% of segs (WITHIN maxsegratio 75%)
whinit returns: ALL EVAL1(w/SEGLIST)
NOTE: Table WORK.TEST created, with 243570 rows and 3 columns.

1590
1591  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           3:31.14
      user cpu time       1.51 seconds
      system cpu time     10.01 seconds
      memory              161854.62k
      OS Memory           191904.00k
      Timestamp           07/25/2018 02:45:25 PM
      Step Count                        79  Switch Count  1


1592
1593  proc sql _method;
1594  create table test as
1595  select enrolid, proc1, proctyp from DWSC1116.CEMR_O_2012_2016 where
1596  PROC1 in (select distinct PROC1 from search_results)
1597  ;

NOTE: SQL execution methods chosen are:

      sqxcrta
          sqxfil
              sqxsrc( DWSC1116.CEMR_O_2012_2016 )

NOTE: SQL subquery execution methods chosen are:

          sqxsubq
              sqxunqs
                  sqxsrc( WORK.SEARCH_RESULTS )
NOTE: Table WORK.TEST created, with 243570 rows and 3 columns.

1598
1599  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1:11:16.42
      user cpu time       13:11.53
      system cpu time     5:04.06
      memory              6516.34k
      OS Memory           36260.00k
      Timestamp           07/25/2018 03:58:42 PM
      Step Count                        80  Switch Count  0


&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 20:11:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481252#M15013</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-25T20:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481289#M15014</link>
      <description>&lt;P&gt;When your query says&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;select enrolid, proc1, proctyp from DWSC1116.CEMR_O_2012_2016 where PROC1 in ('64615')&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and your table is indexed on PROC1, SAS knows where those records are in your large table and only needs to read those. The time required becomes proportional to the size of the result table and not the size of the database table.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jul 2018 21:57:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481289#M15014</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-07-25T21:57:43Z</dc:date>
    </item>
    <item>
      <title>Re: Does the speed of a query decrease with the number of indexes?</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481312#M15015</link>
      <description>&lt;P&gt;SAS should be able to use the index in the other query that uses the subquery.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jul 2018 00:57:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Does-the-speed-of-a-query-decrease-with-the-number-of-indexes/m-p/481312#M15015</guid>
      <dc:creator>harlananelson</dc:creator>
      <dc:date>2018-07-26T00:57:26Z</dc:date>
    </item>
  </channel>
</rss>

