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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Delete followed by Select Count(1) - SLOW

RE: Delete followed by Select Count(1) - SLOW

From: Vergara, Michael (TEM) <mvergara_at_guidant.com>
Date: Thu, 16 Aug 2001 13:43:04 -0700
Message-ID: <F001.0036E15B.20010816140433@fatcity.com>

Truncate basically resets the table's highwater mark to 0. Deletes don't do that. A 'select count(*)' does a full table scan, which much touch all the blocks up to the HWM, and that's what's taking the time. The REUSE STORAGE option keeps the extents allocated to the table, but the HWM is still reset to 0.

At least, that's what I was taught!

HTH,
Mike

---
===========================================================================
Michael P. Vergara
Oracle DBA
Guidant Corporation

(909) 914-2304
-----Original Message----- Sent: Thursday, August 16, 2001 2:33 PM To: Multiple recipients of list ORACLE-L I have a user that deleted all of the rows in a table
(i.e. 100,000), waited for it to complete, and then
ran a SELECT COUNT(1) FROM <table>. It took a few minutes for '0 rows' to be returned to the prompt. The table has ~60 extents (128k ea.). Granted, the number of extents is excessive but it's a development instance and this table is an exception. Is Oracle scanning through all of the blocks, since the space wasn't released, and this is the cause of the latency? The curious thing is that I told this user to use TRUNCATE instead and we talked about using the drop/reuse storage clauses. He performed a TRUNCATE...REUSE STORAGE and the same select and it was night and day in terms of performance. If the allocated space isn't being released in this case also, why is there such a performance difference between the two? -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Vergara, Michael (TEM) INET: mvergara_at_guidant.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- 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 Thu Aug 16 2001 - 15:43:04 CDT

Original text of this message

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