![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX and Linux Applications Questions involving software not covered by other forum go here. This includes Databases and Middleware. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tips for Optimizing Rails on Oracle | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 02:10 AM |
| Optimizing for a Speed-up | switch | Shell Programming and Scripting | 3 | 04-07-2006 05:52 PM |
| optimizing disk performance | J.P | Filesystems, Disks and Memory | 4 | 03-01-2005 08:32 AM |
| Optimizing Apache Server Performance | Neo | News, Links, Events and Announcements | 0 | 02-14-2005 06:30 PM |
| Optimizing the system reliability | Deepa | Filesystems, Disks and Memory | 2 | 12-11-2002 07:09 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Optimizing query
Hi All,
My first thread to this sub-forum and first thread of this sub-forum Here it is, Am trying to delete duplicates from a table retaining just 1 duplicate value out of the duplicate records for example : from n records of a table out of which x are duplicates, I want to remove x - 1 records retaining 1 record from the x duplicates This is the query am using, but I think this could still be optimized for this query really takes time for huge dumps. DELETE FROM tableA WHERE rowid not in (SELECT MIN(rowid) FROM tableA GROUP BY column1) Oracle 9i |
| Forum Sponsor | ||
|
|
|
|||
|
rowid is not an indexed column - it is a "pseudocolumn'. the in () subselect will read thru the entire select statement's result set each time. When I get back in a while I'll write something that is faster. You may need to add an index.
|
|
||||
|
I don't know if this is more efficient, but it seems like a positive approach might be better where there are only a few duplicates.
DELETE FROM tableA A1 WHERE column1 in (SELECT column1 FROM tableA GROUP BY column1 having count(*) > 1) and rowid != (select min(rowid) from tableA A2 where A1.column1 = A2.column1) |
|
|||
|
Quote:
rowid <1> - evaluate sub query rowid <2> - evaluate sub query . . . rowid <n> - evaluate sub query Last edited by reborg; 08-03-2007 at 11:29 AM. Reason: touch post to fix quotes |
|
|||
|
Shell_Life
out of the 4 potential hazards that you have listed since the query is executed only on a table with 0.25 million records, I just encounter the 4th hazard which is taking real long time. When it initially took such a long time, I though I might be receiving ' Long transaction aborted '. But didn't. Considering the alternative of programmatically deleting is a fine idea without filling the logs. |
|
||||
|
Quote:
It is also important to note that the database server does not assign rowids to rows in fragmented tables. Last edited by reborg; 08-03-2007 at 11:29 AM. Reason: touch post to fix quotes |
||||
| Google The UNIX and Linux Forums |