Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> drop table vs truncate table -- performance

drop table vs truncate table -- performance

From: gmei <gmei_at_incyte.com>
Date: Mon, 10 Mar 2003 13:39:31 -0800
Message-ID: <F001.00565494.20030310133931@fatcity.com>


Hi:
Oracle 8173 on Sun Solaris 2.8.
I am running a program that creates and drops tables repeatedly in a schema. The table dropping part looks like this:

drop table ypd.t1 cascade constraints;
drop table ypd.t2 cascade constraints;
drop table ypd.t3 cascade constraints;
drop table ypd.t4 cascade constraints;

....

I thought I might be able to use "truncate table ..." and then "drop table ..." to make this process a bit faster. However the tests I did today showed otherwise:

SQL> select bytes from dba_segments where segment_name='SEQUENCE';

     BYTES



1949810688

SQL> create table ypd_owner.SEQUENCE1
  2 tablespace ypd nologging as select * from mt.SEQUENCE;

Table created.

Elapsed: 00:04:272.50
SQL> drop table ypd_owner.SEQUENCE1;

Table dropped.

Elapsed: 00:00:05.19
SQL> create table ypd_owner.SEQUENCE1
  2 tablespace ypd nologging as select * from mt.SEQUENCE;

Table created.

Elapsed: 00:04:275.85
SQL> truncate table ypd_owner.SEQUENCE1;

Table truncated.

Elapsed: 00:00:06.99
SQL> drop table ypd_owner.SEQUENCE1;

Table dropped.

Elapsed: 00:00:00.70



Tablspace ypd is LMT. Similar test on smaller table showed the same result "drop table ..." is faster than "truncate table ...". Any explanation? TIA. Guang

--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: gmei
  INET: gmei_at_incyte.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Mon Mar 10 2003 - 15:39:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US