<?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: Proc sql - long duration time of deleting data from table in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276448#M58667</link>
    <description>&lt;P&gt;Why are you doing this in SAS. &amp;nbsp;The most efficient way to do this would be to use the database to upload new data. &amp;nbsp;Adding a third party in, even with the best coding in the world, will slow down the overall process.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Jun 2016 09:05:13 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-06-10T09:05:13Z</dc:date>
    <item>
      <title>Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276434#M58661</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have one little problem. Namely I have connection&amp;nbsp;with database (Teradata) through SAS and I am processing sql query on Teradata side. I would like delete data from table, but I have figured out only one solution below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;proc&lt;/FONT&gt;&lt;/STRONG&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;noprint&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;delete&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; DDHDP01P.HP_KHD4491_PESEL;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;The problem is that is completely inefficient and lasts ages. Do you probably know any other (quicker) way to do that.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;Thank you very much.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 07:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276434#M58661</guid>
      <dc:creator>Hb21Pzn</dc:creator>
      <dc:date>2016-06-10T07:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276435#M58662</link>
      <description>&lt;P&gt;I don't know really what hapends with a SQL like this and implict pass thru.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options sastrace=',,,d' sastraceloc=saslog nostsuffix msglevel=i;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will might give you some hints on what's going on.&lt;/P&gt;
&lt;P&gt;By a quick Google search, the Teradata DELETE ALL should be the quickest&amp;nbsp;way to empty&amp;nbsp;a table. If SAS&amp;nbsp;doesn't give you this, try that in an explicit&amp;nbsp;SQL pass thru step.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 07:40:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276435#M58662</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-06-10T07:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276438#M58663</link>
      <description>&lt;P&gt;Yes, of course I know that DELETE TABLE is fastest way to do this kind of think but I am creating the automation process in which I need delete data from table before next prod append.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway thank you for your response and I see how helpfull it will be when I would follow your advise.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 08:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276438#M58663</guid>
      <dc:creator>Hb21Pzn</dc:creator>
      <dc:date>2016-06-10T08:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276439#M58664</link>
      <description>&lt;P&gt;The quickest way (edit: in SAS!) is to delete the table and recreate it.&lt;/P&gt;
&lt;P&gt;Using "delete from" forces ths DBMS to scan the table record by record and delete every single one; no wonder that it lasts ages, I would be hard pressed to find a less efficient way.&lt;/P&gt;
&lt;P&gt;I'd try something like&lt;/P&gt;
&lt;P&gt;- rename the table&lt;/P&gt;
&lt;P&gt;- recreate the original table from the renamed table with obs=0&lt;/P&gt;
&lt;P&gt;- delete the renamed table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, if you have a library defined for the DBMS:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data library.table;
set library.table (obs=0);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if the DBMS supports that kind of operation.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 08:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276439#M58664</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-10T08:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276442#M58665</link>
      <description>&lt;P&gt;I wrote "DELETE ALL", not DELETE TABLE, which I don't think exists, you may think of DROP TABLE?&lt;/P&gt;
&lt;P&gt;Se this thread that elaborates between the two:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://stackoverflow.com/questions/27818798/teradata-delete-all-vs-dropcreate" target="_blank"&gt;http://stackoverflow.com/questions/27818798/teradata-delete-all-vs-dropcreate&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 08:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276442#M58665</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-06-10T08:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276446#M58666</link>
      <description>&lt;P&gt;Yes I meant delete all. I wrote it without previous checkicng and that was result of this inaccuracy.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 09:01:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276446#M58666</guid>
      <dc:creator>Hb21Pzn</dc:creator>
      <dc:date>2016-06-10T09:01:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276448#M58667</link>
      <description>&lt;P&gt;Why are you doing this in SAS. &amp;nbsp;The most efficient way to do this would be to use the database to upload new data. &amp;nbsp;Adding a third party in, even with the best coding in the world, will slow down the overall process.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 09:05:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276448#M58667</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-10T09:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276456#M58672</link>
      <description>&lt;P&gt;I have taken over&amp;nbsp;the procces&amp;nbsp;of automation&amp;nbsp;and I am still trying to improve few things. We have changed the tool for automation in my company&amp;nbsp;and that's why I am doing this in SAS.&amp;nbsp;Moreover&amp;nbsp;I am fully aware that SAS&amp;nbsp; is not most efficient way to uploading data.&lt;/P&gt;&lt;P&gt;Generally everything is being worked well, but the most significant problem turning out beceouse of this thing.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 10:02:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276456#M58672</guid>
      <dc:creator>Hb21Pzn</dc:creator>
      <dc:date>2016-06-10T10:02:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276519#M58678</link>
      <description>&lt;P&gt;As a variation of Kurt's suggestion, create a table with the structure you need and no records. You could then overwrite the table with empty one.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 15:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276519#M58678</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-06-10T15:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276537#M58680</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88478"&gt;@Hb21Pzn﻿&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think the performance question is still not answered. Why does a "delete from table"&amp;nbsp; takes so long for an RDBMS? First of all this is not a SAS issue. If you do this in Teradata admin or BTEQ it will take equally long. For starters it is because the RDBMS does journalling.&amp;nbsp; When a transaction fails it needs to be rolled back. Creating such a rollback log is very expensive and caqn potentially overflow buffers and bring a system down. Secondly an index may need rework for every deleted row. Also very expensive indeed.&amp;nbsp; Another cause can be the repeated validation of referential integrity (RI) constraints. If another table has a integrity dependency on your table every delete will require a validation of that constraint. These checks can be disabled or postponed but sooner or later they will cost you. Due to al this a "delete from table" is considered bad practice and will lead to a visit and a fatherly speach from your trusty DBA if you do it often (meaning more than once).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oracle has a TRUNCATE function. TD has the ALL keyword: DELETE&amp;nbsp; FROM TABLE ALL;.&amp;nbsp; In TD the ALL keyword avoids transaction logging of each row's deletion. It wipes the cyliner headers and marks the tables as empty. It is called a fastpath delete. This means a brute force deletion of rows neglecting indexes and RI constraints. Messy but fast. Maybe just what you need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The DI Studio data loader has options for you to choose how to clear data from a table because of all this. Hope you can now&amp;nbsp; tell why.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So that's why dropping and re-creating the table altogether is often your best bet. Or maybe, if you use explicit passthrough, you can code the ALL keyword in your SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;* Edited for typos.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jun 2016 16:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/276537#M58680</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-10T16:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql - long duration time of deleting data from table</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/277153#M58728</link>
      <description>Thank you very much. I will try it and maybe it would that what I am looking for so long &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Jun 2016 08:22:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-sql-long-duration-time-of-deleting-data-from-table/m-p/277153#M58728</guid>
      <dc:creator>Hb21Pzn</dc:creator>
      <dc:date>2016-06-14T08:22:06Z</dc:date>
    </item>
  </channel>
</rss>

