<?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: Create index on local temporary table - automatic commit in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837715#M4868558</link>
    <description>&lt;P&gt;&amp;gt; this could be a separate question but I don't want to flood the forum&lt;/P&gt;
&lt;P&gt;Separate questions should always be separate questions, never continuations of another discussion. Flooding is not an issue.&lt;/P&gt;</description>
    <pubDate>Thu, 03 Apr 2014 10:50:30 GMT</pubDate>
    <dc:creator>Breck_Carter</dc:creator>
    <dc:date>2014-04-03T10:50:30Z</dc:date>
    <item>
      <title>Create index on local temporary table - automatic commit</title>
      <link>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaq-p/13837712</link>
      <description>&lt;P&gt;Automatic commit is a side effect of issuing CREATE INDEX statement even on local temporary tables. Questions:&lt;BR /&gt;
 1. Is it really necessary (technically) on local temporary tables?&lt;BR /&gt;
 2. How could we avoid automatic commits when calling a procedure which declares local temporary tables and creates indexes on them (for performance reasons)?&lt;BR /&gt;
I think, SA version is not important here, since all versions behave the same.&lt;BR /&gt;
Waiting for any hints. Thanks.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Edited:&lt;/STRONG&gt; Following Volker's answer, my primary statement that all versions behave the same was incorrect. So I'm currently more interested in SA11 and SA12.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 05:10:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaq-p/13837712</guid>
      <dc:creator>former_SQLA_member1694875</dc:creator>
      <dc:date>2014-04-03T05:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create index on local temporary table - automatic commit</title>
      <link>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837713#M4868556</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I think, SA version is not important here, since all versions behave the same.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not fully true: v16 has introduced a changed behaviour here (and obviously an improvement from your point of view:) - cf. the &lt;A href="http://dcx.sybase.com/index.html#sa160/en/sachanges/sa-16-nagano-sectb-3789082.html"&gt;docs&lt;/A&gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;Default behavior has changed when creating indexes on local temporary tables&lt;/STRONG&gt;   In previous releases, the database server always executed a COMMIT before creating an index on a local temporary table. Now, the database server does not perform a COMMIT before creating an index on a local temporary table. You can control this behavior by setting the auto_commit_on_create_local_temp_index database option. See &lt;A href="http://dcx.sybase.com/index.html#sa160/en/dbadmin/da-dboptions-force-commit-on-create-index-option.html"&gt;auto_commit_on_create_local_temp_index option&lt;/A&gt;. &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;
&lt;P&gt;That being said, it seems not possibly to omit the automatic commit in v12 and below - you might only re-organize your code to pre-create the temporary table and index before the stored procedure is called and truncate the table afterwards. I am not sure whether that would lead to a worse performance...&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 06:03:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837713#M4868556</guid>
      <dc:creator>VolkerBarth</dc:creator>
      <dc:date>2014-04-03T06:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create index on local temporary table - automatic commit</title>
      <link>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837714#M4868557</link>
      <description>&lt;P&gt;Oops, I missed that. Thanks. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; I've edited my question.&lt;BR /&gt;
Is there a better way to check if local temporary table already exists (this could be a separate question but I don't want to flood the forum)?
&lt;/P&gt;&lt;PRE&gt;...
begin
  select 1 into &lt;A href="https://sqlanywhere-forum.sap.com/users/320/arthoor/"&gt;@a&lt;/A&gt; from #tmp;
  exception when others then ... //create temp. table and index
end
...
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This is what we should check in the procedure if we pre-create temporary tables somewhere outside since the procedure can be called from different places and pre-creation would take place only where the logic is sensitive to that side effect.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 07:44:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837714#M4868557</guid>
      <dc:creator>former_SQLA_member1694875</dc:creator>
      <dc:date>2014-04-03T07:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create index on local temporary table - automatic commit</title>
      <link>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837715#M4868558</link>
      <description>&lt;P&gt;&amp;gt; this could be a separate question but I don't want to flood the forum&lt;/P&gt;
&lt;P&gt;Separate questions should always be separate questions, never continuations of another discussion. Flooding is not an issue.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Apr 2014 10:50:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-index-on-local-temporary-table-automatic-commit/qaa-p/13837715#M4868558</guid>
      <dc:creator>Breck_Carter</dc:creator>
      <dc:date>2014-04-03T10:50:30Z</dc:date>
    </item>
  </channel>
</rss>

