<?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>Question Re: Query optimization issue in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818742#M4849585</link>
    <description>&lt;P&gt;Thank you for your replay. I will recheck my queries, seem like I missed something.&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jun 2013 09:42:19 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-06-26T09:42:19Z</dc:date>
    <item>
      <title>Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaq-p/13818737</link>
      <description>&lt;P&gt;Hi,
Running SQLAnywhere 11.01, I'm trying to optimize a query. After some changes on initial query, I get an execution plan that seems to be faster (RunTime - old value = 1415.1, new value = 614.07), but when I run this query in my application, the total execution time increased from ~2 min to ~4 min. 
Can anyone explain why this happens and can I do something to receive a better application run time for this query?&lt;BR /&gt;
&lt;A href="http://www.4shared.com/zip/g0FDWRyf/Query_exec_plans.html" target="_blank"&gt;Here&lt;/A&gt; are attached exec plans (before and after my changes).&lt;/P&gt;
&lt;P&gt;Note: before running this query, I created statistics on all involved tables.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2013 05:42:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaq-p/13818737</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-25T05:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818739#M4849582</link>
      <description>&lt;P&gt;to download your plans, &lt;A href="http://4shared.com"&gt;4shared.com&lt;/A&gt; demand registration. Is it possible to use another hosting?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 03:58:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818739#M4849582</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-26T03:58:29Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818740#M4849583</link>
      <description>&lt;P&gt;Sorry about that, &lt;A href="http://www.megafileupload.com/en/file/429659/Query-exec-plans-zip.html"&gt;this&lt;/A&gt; is a new link on megafileupload&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 04:25:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818740#M4849583</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-26T04:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818741#M4849584</link>
      <description>&lt;P&gt;Note that you can always upload your plans to this site - just use the 'paperclip' icon to attach a file.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 09:13:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818741#M4849584</guid>
      <dc:creator>MarkCulp</dc:creator>
      <dc:date>2013-06-26T09:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818738#M4849581</link>
      <description>&lt;P&gt;The plans you have uploaded are only providing &lt;EM&gt;estimates&lt;/EM&gt; for all operations, but especially in terms of both rows returned:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Before:&lt;/STRONG&gt; RowsReturned 1.0689e+06&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;After:&lt;/STRONG&gt; RowsReturned 2.4637e+05&lt;/P&gt;
&lt;P&gt;and run times:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Before:&lt;/STRONG&gt; RunTime 1415.1&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;After:&lt;/STRONG&gt; RunTime 614.07&lt;/P&gt;
&lt;P&gt;This is done before the engine actually goes to execute the queries and is not the &lt;EM&gt;actual&lt;/EM&gt; run time in the engine. You need to instead gather a &lt;A href="http://dcx.sybase.com/index.html#1101/en/dbusage_en11/ug-optimizer-s-5059382.html"&gt;graphical plan &lt;STRONG&gt;with statistics&lt;/STRONG&gt;&lt;/A&gt;, so that the engine actually runs the SQL statement and monitors how long each operation &lt;EM&gt;actually&lt;/EM&gt; takes.&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;The graphical plan with statistics,
though more expensive to generate,
provides the actual query execution
statistics as monitored by the
database server when the query is
executed, and permits direct
comparison between the estimates used
by the optimizer in constructing the
access plan with the actual statistics
monitored during execution.
Significant differences between actual
and estimated statistics might
indicate that the optimizer does not
have enough information to correctly
estimate the query's cost, which may
result an inefficient execution plan.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This is likely the cause of your run time cost discrepancy. Notably, the estimates for the amount of rows being returned is large (1068900 vs 246370), so I would start reviewing how many rows are actually being returned in each of these cases to see if the estimates are off or not.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 09:35:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818738#M4849581</guid>
      <dc:creator>jeff_albion</dc:creator>
      <dc:date>2013-06-26T09:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818742#M4849585</link>
      <description>&lt;P&gt;Thank you for your replay. I will recheck my queries, seem like I missed something.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 09:42:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818742#M4849585</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-06-26T09:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818743#M4849586</link>
      <description>&lt;P&gt;...if you have enough rep points (100, according to the FAQ), which John has not yet - or is that restriction obsolete?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 09:54:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818743#M4849586</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2013-06-26T09:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Query optimization issue</title>
      <link>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818744#M4849587</link>
      <description>&lt;P&gt;Good point which I had forgotten. The restriction is still at 100 reps.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2013 10:51:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/query-optimization-issue/qaa-p/13818744#M4849587</guid>
      <dc:creator>MarkCulp</dc:creator>
      <dc:date>2013-06-26T10:51:36Z</dc:date>
    </item>
  </channel>
</rss>

