Re: Oracle cursor help
- From: frank.ullrich@xxxxxxxx (Dr. Frank Ullrich)
- Date: Thu, 23 Jun 2005 09:50:15 +0200
Steve,
maybe this whole thing doesn't really belong here but anyway:
Steve Sapovits wrote:
I have a few Oracle tables that have gotten way too big. Normal DELETE/WHERE clauses consume too many resources. I know enough to know that cursors would be more efficient here but I don't
How do you know that? According to a leading expert in the field of performant Oracle programming that would be the worst approach:
<quote>
*There is nothing good about row at a time processing, it is something to do ONLY when a set based operation isn't feasible*
</quote> This is one statements of many in that thread: http://asktom.oracle.com/pls/ask/f?p=4950:8:10872697057937345780::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6407993912330
know enough to actually start using them. Does anyone have an example or two (or three) to bootstrap me? What I'd essentially want to do is loop through all rows, look at a few column settings, and delete those that fall into certain categories (e.g., certain dates being so old and certain status fields not being set to a set value, etc.). I can also limit the row set up front with a pretty simple WHERE clause -- whatever is more efficient is what I'm aiming for (it wasn't clear to me if limiting up front with WHERE clauses defeated the efficiency of cursors ...)
So my impression is: do it with a single SQL operation (set based approach) or several set operations if you can divide the task into smaller units.
Maybe this discussion on LIOs (logical ios and how to minimize them) is also heplful:
http://asktom.oracle.com/pls/ask/f?p=4950:8:3182666695492247015::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:6749454952894
As for the deletes: maybe it's worth to consider keeping the records you need and pushing them into a new table ("create table as select". Even parallelized and/or without logging; that depends). After that drop the old table and rename the new one.
Can you work with the parallel options (Oracle Enterprise Edition)?
I believe that before starting such big operations one should try to evaluate the many different options one luckily has with Oracle.
Good luck.
Regards, Frank.
-- Dr. Frank Ullrich, DBA Netzwerkadministration Heise Zeitschriften Verlag GmbH & Co KG, Helstorfer Str. 7, D-30625 Hannover E-Mail: frank.ullrich@xxxxxxxx Phone: +49 511 5352 587; FAX: +49 511 5352 538
.
- References:
- Oracle cursor help
- From: Steve Sapovits
- Oracle cursor help
- Prev by Date: Oracle cursor help
- Next by Date: ODBC and tables 'v' views
- Previous by thread: Oracle cursor help
- Next by thread: Re: Oracle cursor help
- Index(es):
Relevant Pages
|