删除大表时,为了控制cpu消耗,我们可以采用以下办法,分步进行删除,以下信息摘自metalink ID 68836.1
Permanent object cleanup
~~~~~~~~~~~~~~~~~~~~~~~~
If a permanent object (table) is made up of many extents, and the object is
to be dropped, the user process dropping the object will consume large
amounts of CPU - this is an inescapable fact. However, with some forethought
it is possible to mitigate the effects of CPU usage (and hence the knock-on
effect on other users of system resources) thus:
1. Identify, but do NOT drop the table
2. Truncate the table, specifying the REUSE STORAGE clause. This will be
quick as extents are not deallocated; the highwater mark is simply
adjusted to the segment header block.
3. Deallocate unused extents from the table, SPECIFYING THE KEEP CLAUSE.
This is the crux - you can control how many extents are to be deallocated
by specifying how much (in terms of Kb or Mb) of the table is NOT
to be deallocated.
Example:
o. Table BIGTAB is 2Gb in size and consists of 262144 8Kb extents
o. There is little CPU power available, and (from past experience) it is
known that dropping an object of this number of extents can take days
o. The system is quiet at night times (no other users or batch jobs)
In the above example the table could be dropped in 'phases' over the period
of a few nights as follows:
1. Truncate the table, specifying the REUSE STORAGE clause:
SQL> TRUNCATE TABLE BIGTAB REUSE STORAGE;
2. If it takes 3 days (72 hours) to drop the table, spread this out over
6 nights i.e. drop 1/3 Gb per night. This can be achieved in 6 (nightly)
steps as follows:
Night 1:
SQL> ALTER TABLE BIGTAB DEALLOCATE UNUSED KEEP 1707M; (2Gb*5/6)
Night 2:
SQL> ALTER TABLE BIGTAB DEALLOCATE UNUSED KEEP 1365M; (2Gb*4/6)
Night 3:
SQL> ALTER TABLE BIGTAB DEALLOCATE UNUSED KEEP 1024M; (2Gb*3/6)
Night 4:
SQL> ALTER TABLE BIGTAB DEALLOCATE UNUSED KEEP 683M; (2Gb*2/6)
Night 5:
SQL> ALTER TABLE BIGTAB DEALLOCATE UNUSED KEEP 341M; (2Gb*1/6)
Night 6:
SQL> DROP TABLE BIGTAB;
The same method can be applied if LOB segments or indexes are involved.
SQL> ALTER TABLE <table_name> MODIFY LOB (<lob_column>)
DEALLOCATE UNUSED KEEP <value>M;
SQL> ALTER INDEX <index_name> DEALLOCATE UNUSED KEEP <value>M;
分享到:
相关推荐
DDR4接口分析是现代高速数字设计中的一个关键环节,特别是在高性能计算和数据中心应用中。Cadence公司的DDR4接口分析课程提供了深入理解如何有效地处理这一挑战的途径。在2015年的MemCon会议上,Taranjit Kukal和...
How to read a book efficiently. Part one The dimensions of reading Part two The third level of reading Part three Approaches to different kinds of reading Part four The ultimate goals of reading
How to perform large scale operations efficiently
While most developers today use object-oriented languages, the full power of objects is available only to those with a deep understanding of the object paradigm. How to Use Objects will help you gain ...
The book aims to provide developers with a deep but concise understanding of how to efficiently work with MongoDB. Table of Contents Introduction Schema Basics One-To-One (1:1) One-To-Many (1:N) Many...
Learn how to efficiently read and write data in R Dive into data carpentry—the vital skill for cleaning raw data Optimize your code with profiling, standard tricks, and other methods Determine your ...
The examples illustrate how to carry out some of the most common database operations, including creating a database and table, loading data in a CSV input file into a database table, updat‐ ing ...
known but equally powerful features that will ensure you become a top-level performant and professional user, able to jump between multiple sessions while manipulating and controlling with ease many ...
You will not only learn about group-wise data manipulation, but also learn how to efficiently handle date, string, and factor variables along with different layouts of datasets using the reshape2 ...
You’ll also study how to efficiently and effortlessly manage a microservice-based architecture. What you will learn Learn how to design microservice-based systems Create services that fail ...
By the end of the book, you will have the knowledge to efficiently solve certain scenarios, you will know which is the best solution architecture to propose to a customer and how to implement it. ...
Just as the organization of a telephone directory makes it easy for a person to search, SQL Server quickly searches a table with a clustered index. Because a clustered index determines the sequence ...
you'll also work with fields and chart enhancements and learn how to create a data model with faster data model acceleration. Once this is done, you will learn about XML dashboards, working with apps...
With exercises and real-world examples in each chapter, this book will teach even those who have never programmed before all the tools necessary to build powerful databases and access information ...