<?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: Pass-through query to SQL Server takes a long time to run... in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212244#M15895</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're doing a &lt;STRONG&gt;&lt;EM&gt;select distinct *&lt;/EM&gt;&lt;/STRONG&gt; outside of your pass-through. This causes SAS to do a sort by all variables in the local SAS server. Move that distinct into the pass-through, so that it is executed in the DB.&lt;/P&gt;&lt;P&gt;Or do a proper sort after the SQL to eliminate multiple entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 24 Jun 2015 05:52:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2015-06-24T05:52:58Z</dc:date>
    <item>
      <title>Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212239#M15890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;4.3&lt;BR /&gt;As the title states, I have a program in a process flow that pulls in data from SQL Server via a pass-through query.&amp;nbsp; The problem is that it takes a LOT longer to run in Enterprise Guide than in SQL Server Management Studio.&amp;nbsp; My SQL is identical.&amp;nbsp; In Management Studio it runs in 1 minutes 17 seconds.&amp;nbsp; In Enterprise Guide I kill it after 11 minutes (before I get an angry call or email from our DBA).&amp;nbsp; Since the actual SQL submitted to SQL Server isn't the issue, I'm posting only the SAS-specific code.&amp;nbsp; Hopefully someone can help.&amp;nbsp; I have searched everywhere and am posting because I have exhausted other options.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;%let dsnname = ODBC_DATA_SOURCE_NAME;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;connect to odbc as dw (dsn="&amp;amp;dsnname" uid=USERNAME pwd=PASSWORD);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt; create table work.output_dataset as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; select distinct &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; * &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; from connection to dw &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt; ......SQL CODE SENT TO SQL SERVER.......&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; order by&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; column1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; ,column2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; ,column3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; ,column4;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;disconnect from dw;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 16:22:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212239#M15890</guid>
      <dc:creator>H4xc1ty</dc:creator>
      <dc:date>2015-06-23T16:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212240#M15891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a couple of issues here. I assume that when you say "My SQL is identical", you're referring to the contents of your "SQL CODE SENT..." block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you are doing several other things here:&lt;/P&gt;&lt;P&gt;1. You're sorting your result set by four variables;&lt;/P&gt;&lt;P&gt;2. You're transferring the result set from your physical database server to your physical SAS server;&lt;/P&gt;&lt;P&gt;3. You're loading the data into "work.output_dataset" on your physical SAS server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably, your delay lies in one of these factors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems odd that you don't include your "order by" clause in your pass through SQL. If you do, does it make a difference to your Management Studio times?&lt;/P&gt;&lt;P&gt;During the 11 minutes, do you know for a fact that your database server is chugging hard on your request (therefore steaming your DBA), or could the database server be fairly quiescent?&lt;/P&gt;&lt;P&gt;Is your result dataset bigger than 20 GB? Anything under that shouldn't present major problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 16:49:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212240#M15891</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2015-06-23T16:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212241#M15892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a couple of issues here. I assume that when you say "My SQL is identical", you're referring to the contents of your "SQL CODE SENT..." block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you are doing several other things here:&lt;/P&gt;&lt;P&gt;1. You're sorting your result set by four variables;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I do this because event though I include it in my passthrough SQL Enterprise Guide (or proc sql, not sure which) will automatically reorder data by column order if I don't&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2. You're transferring the result set from your physical database server to your physical SAS server;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; It is probably worth noting that we don't have an actual SAS server we use Enterprise Guide with the Local Server.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;3. You're loading the data into "work.output_dataset" on your physical SAS server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably, your delay lies in one of these factors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems odd that you don't include your "order by" clause in your pass through SQL. &lt;STRONG&gt;(see above) &lt;/STRONG&gt;If you do, does it make a difference to your Management Studio times? &lt;STRONG&gt;(no)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;During the 11 minutes, do you know for a fact that your database server is chugging hard on your request (therefore steaming your DBA), or could the database server be fairly quiescent?&lt;/P&gt;&lt;P&gt;Is your result dataset bigger than 20 GB? Anything under that shouldn't present major problems.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212241#M15892</guid>
      <dc:creator>H4xc1ty</dc:creator>
      <dc:date>2015-06-23T17:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212242#M15893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. I have never seen PROC SQL or Enterprise Guide reorder output data...this seems very, very odd.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. Based on your reply, my first area of investigation would be the data transfer speed to your local PC. Can you monitor the throughput of the network throughput to your machine, and see it it's maxed out over the 11 minute duration? I've seen cases where server-to-server communication is very fast (GB or 10 GB / second), but the runs to the local machines are 10 MB or 100 MB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another way to check this is just to copy a file that's about the same size as your SAS result from a server to your PC, and see how long it takes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 17:38:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212242#M15893</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2015-06-23T17:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212243#M15894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Run this test. It should run at a similar speed to your SQL Server Management Studio version. If so then you can assume that it is the transferring of the data back to your PC that is the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I agree with Tom - reordering your data again in SAS should not be necessary, unless it is some unusual issue with ordering missing or null values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;connect to odbc as dw (dsn="&amp;amp;dsnname" uid=USERNAME pwd=PASSWORD);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; select count(*)&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; from connection to dw &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; (&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt; ......SQL CODE SENT TO SQL SERVER.......&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;&amp;nbsp; ;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;disconnect from dw;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff; font-family: terminal,monaco; font-size: 10pt;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2015 19:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212243#M15894</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2015-06-23T19:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212244#M15895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're doing a &lt;STRONG&gt;&lt;EM&gt;select distinct *&lt;/EM&gt;&lt;/STRONG&gt; outside of your pass-through. This causes SAS to do a sort by all variables in the local SAS server. Move that distinct into the pass-through, so that it is executed in the DB.&lt;/P&gt;&lt;P&gt;Or do a proper sort after the SQL to eliminate multiple entries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2015 05:52:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212244#M15895</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2015-06-24T05:52:58Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212245#M15896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a typical problem when using explicit SQL pass-thru, you must be aware on what is happening where.&lt;/P&gt;&lt;P&gt;if you tried implicit pass-thru, SAS will automatically send any appropriate part of the code to the source DB, and in most cases, it does what's optimal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jun 2015 06:48:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/212245#M15896</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-06-24T06:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Pass-through query to SQL Server takes a long time to run...</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/243756#M17372</link>
      <description>&lt;P&gt;Hi, Just saw this old discussion. Did you get any solution? I have a similar problem.&amp;nbsp;The answers about sorting, select distinct&amp;nbsp;and transferring data is not the problem. (Just attempts of explantions). &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In my query&amp;nbsp;I get&amp;nbsp;30000 raws in the result-table. In SQL Server Management Studio it took more or less 10 sec. In EG, it took half an hour!!&lt;/P&gt;&lt;P&gt;I have preassigned my library to get advantages from pass-though. This&amp;nbsp;works well in 99%&amp;nbsp;of our queries.&lt;/P&gt;&lt;P&gt;Explicit pass-through will definately help, even it is not a smooth solution.&lt;/P&gt;&lt;P&gt;Then....&lt;/P&gt;&lt;P&gt;I tried with &lt;STRONG&gt;select top n&lt;/STRONG&gt; ... in the sql-code within the parentesis (SQL Server-side). Nice!! I wrote &lt;STRONG&gt;select top 50000...&lt;/STRONG&gt; It helped even if my result-dataset was only 30k. With no top-stmt it took much longer time.&lt;/P&gt;&lt;P&gt;In my case it depends on the complexity of the query and the tables in the query. When I removed one table (not the biggest) it&amp;nbsp;used again 10sec to get 30k raws in the result-dataset.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2016 12:50:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Pass-through-query-to-SQL-Server-takes-a-long-time-to-run/m-p/243756#M17372</guid>
      <dc:creator>ToreB</dc:creator>
      <dc:date>2016-01-15T12:50:56Z</dc:date>
    </item>
  </channel>
</rss>

