Performance of delete statement
This delete statement does not complete even after 20 hrs. I have indexes on all columns mentioned in the where clause. I have also tried using function based indexes and analyzing tables but this does not give ay results.
When I remove the nvl it processes in 1min. There are 400,000 records in edw_err_invoice_Stg. Can anybody suggest anything ?
delete from stgown.EDW_ERR_INVOICE_STG a
where a.dwh_load_key != (select max(b.dwh_load_key)
from EDW_ERR_INVOICE_STG b
where NVL(a.sys_ent_id,0) = NVL(b.sys_ent_id,0)
and NVL(a.invoice_no,0) = NVL(b.invoice_no,0)
and NVL(a.invoice_line_no,0) = NVL(b.invoice_line_no,0)
and NVL(a.invoice_transaction_date,trunc(sysdate)) = NVL(b.invoice_transaction_date,trunc(sysdate))
and NVL(a.supplier_no,0) = NVL(b.supplier_no,0)
and NVL(a.transaction_flag,0) = NVL(b.transaction_flag,0));
Hi,
What about :
delete from EDW_ERR_INVOICE_STG
where rowid not in (select max(rowid) keep (dense_rank last order by dwh_load_key)
from EDW_ERR_INVOICE_STG
group by sys_ent_id, invoice_no, invoice_line_no, invoice_transaction_date, supplier_no, transaction_flag));Nicolas.
Well, perhaps if you've 2 rows with max value for same group by, it's not a solution... because the statement above keep only one of these.
Message was edited by:
N. Gasparotto
Similar Messages
-
Forcing nologging hint in the delete statement
Hi,
We are forcing nologging hint in the delete statement to improve the performance of delete statement.
DELETE /*+ nologging */ FROM A
Table and Tablespace level Logging is set to Yes. Our database is running in archivelog mode and we have physical standby database.
I would like to know the following.
1. redo entries will be generated or not during the delete opeation with nologging hint
2. If no, how records will be deleted in the standby database
3. Do we really gain performance with nologging in the delete statement
Thanks.You mean that, nologgin hint ...First, there is no such thing as a nologging hint. At least I've never heard of one, documented or undocumented.
Second, as Herman said, DELETE is always logged. In fact DML is always logged except for direct path inserts. -
How to improve Performance of the Statements.
Hi,
I am using Oracle 10g. My problem is when i am Execute & fetch the records from the database it is taking so much time. I have created Statistics also but no use. Now what i have to do to improve the Performance of the SELECT, INSERT, UPDATE, DELETE Statements.
Is it make any differents because i am using WindowsXP, 1 GB RAM in Server Machine, and WindowsXP, 512 GB RAM in Client Machine.
Pls. Give me advice for me to improve Performance.
Thank u...!What and where to change parameters and values ?Well, maybe my previous post was not clear enough, but if you want to keep your job, you shouldn't change anything else on init parameter and you shouldn't fall in the Compulsive Tuning Disorder.
Everyone who advise you to change some parameters to some value without any more info shouldn't be listen.
Nicolas. -
Delete statement that uses a sub-select with the statement in the cursor
Hi all,
How to write write a delete statement that uses a sub-select with the statement in the cursor?
CURSOR excluded_dates IS
SELECT TO_TIMESTAMP(report_parameter_value, in_date_format_mask)
INTO my_current_date_time
FROM report_parameters
WHERE report_parameters.report_parameter_id = in_report_parameter_id
AND report_parameters.report_parameter_group = 'DATE_TIME'
AND report_parameters.report_parameter_name = 'EXCLUDED_DATE';
OPEN excluded_dates;
LOOP
FETCH excluded_dates INTO my_excluded_date;
EXIT WHEN excluded_dates%NOTFOUND;
DELETE FROM edr_rpt_tmp_inclusion_table
WHERE TO_CHAR(date_time, 'mm/dd/yyyy') = TO_CHAR(my_excluded_date, 'mm/dd/yyyy');
END LOOP;
CLOSE excluded_dates;ThanksHi,
In such case I think is better to create a view an perform the delete using it. Example (using HR schema):
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as hr
SQL> create or replace view v_employees as select * from employees where first_name like 'J%';
View created
SQL> select * from v_employees;
EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID
110 John Chen JCHEN 515.124.4269 28/09/1997 FI_ACCOUNT 8200,00 108 100
112 Jose Manuel Urman JMURMAN 515.124.4469 07/03/1998 FI_ACCOUNT 7800,00 108 100
125 Julia Nayer JNAYER 650.124.1214 16/07/1997 ST_CLERK 3200,00 120 50
127 James Landry JLANDRY 650.124.1334 14/01/1999 ST_CLERK 2400,00 120 50
131 James Marlow JAMRLOW 650.124.7234 16/02/1997 ST_CLERK 2500,00 121 50
133 Jason Mallin JMALLIN 650.127.1934 14/06/1996 ST_CLERK 3300,00 122 50
139 John Seo JSEO 650.121.2019 12/02/1998 ST_CLERK 2700,00 123 50
140 Joshua Patel JPATEL 650.121.1834 06/04/1998 ST_CLERK 2500,00 123 50
145 John Russell JRUSSEL 011.44.1344.429268 01/10/1996 SA_MAN 14000,00 0,40 100 80
156 Janette King JKING 011.44.1345.429268 30/01/1996 SA_REP 10000,00 0,35 146 80
176 Jonathon Taylor JTAYLOR 011.44.1644.429265 24/03/1998 SA_REP 8600,00 0,20 149 80
177 Jack Livingston JLIVINGS 011.44.1644.429264 23/04/1998 SA_REP 8400,00 0,20 149 80
181 Jean Fleaur JFLEAUR 650.507.9877 23/02/1998 SH_CLERK 3100,00 120 50
186 Julia Dellinger JDELLING 650.509.3876 24/06/1998 SH_CLERK 3400,00 121 50
189 Jennifer Dilly JDILLY 650.505.2876 13/08/1997 SH_CLERK 3600,00 122 50
200 Jennifer Whalen JWHALEN 515.123.4444 17/09/1987 AD_ASST 4400,00 101 10
16 rows selected
SQL> delete from v_employees where hire_date >= to_date('01/06/1998', 'dd/mm/yyyy');
2 rows deleted
SQL> regards, -
Looping delete statement where table name is coming from another table
Hi All,
We have to write code to delete records from active tables of WDSO.We have 5 DSO so inspite of writing delete statement for each table we want to put all table names into one table and then loop through it .but we are getting error when we are refering that table field which has active table name.error is :
"dictionary structure or table is either not active or does not exist "
As per my understanding in a delete /select /insert /update statement we need to put table name (whose field we are refering ) it can't be replaced by a variable .
ex: v_table = 'EMPLOYEE' .
DELETE FROMv_table WHERE EMP_NAME = 'ABDC' .
is wrong and it must be like
ex : DELETE FROM EMPLOYEE WHERE EMP_NAME = 'ABDC' .
but we want to make our code dynamic .
Can you please suggest a way so that we can read the table names from another table and delete data based on some selection fom those tables .
I tried variants ,perform etc and even searched FM for the same but not found a solution .Your help will be greatly appreciated .
Thanks in advance .
Regards,
JayaHi,
You can change your statement as follows:
DELETE FROM (v_table) WHERE EMP_NAME = 'ABDC' .
However, I would not recommend this. There is a standard function module RSAN_ODS_DATA_DELETE which allows selective deletion - that should be a safer way to do this. You can -
hi
I need to maintain records in a table1 only latest 2 records .
remaining i nee to delete
can any one help me out in delete statement
Table1 contains below columns
empno deptno lastupdatedateThe below query will delete all the rows except the 2 latest record -
DELETE TABLE1
WHERE (EMPNO, DEPTNO, LASTUPDATEDATE) NOT IN (
SELECT EMPNO, DEPTNO, LASTUPDATEDATE
FROM (SELECT EMPNO, DEPTNO, LASTUPDATEDATE
FROM TABLE1
ORDER BY LASTUPDATEDATE DESC)
WHERE ROWNUM <= 2);
There is similar thread already answered for this. You can refer the below link -
Performing Top-N Analysis -
Question about delete statement
I have question about delete statement...
i am performing some simple delete statement against one table..but its taking so long..How can we check whether particular delete statements actually deleting records or not..?Is the associated select-statement returning rows or not?
If yes -> delete is deleting
If no -> delete is just using CPU-cycles
To tune the delete-statement, you have to tune the corresponding select-statement. To tune the select-statement, you want to read the thread When your query takes too long ... -
How to improve performance of insert statement
Hi all,
How to improve performance of insert statement
I am inserting 1lac records into table it takes around 20 min..
Plz help.
Thanx In Advance.I tried :
SQL> create table test as select * from dba_objects;
Table created.
SQL> delete from test;
3635 rows deleted.
SQL> commit;
Commit complete.
SQL> select count(*) from dba_extents where segment_name='TEST';
COUNT(*)
4
SQL> insert /*+ APPEND */ into test select * from dba_objects;
3635 rows created.
SQL> commit;
Commit complete.
SQL> select count(*) from dba_extents where segment_name='TEST';
COUNT(*)
6
Cheers, Bhupinder -
DELETE Statement takes long time running
Hi,
DELETE statements take a very long time to complete.
Can you advice me how can I diagnostic the slow performance
ThanksDeleting rows can be an expensive operation.
Oracle stores entire row as the 'before image' of deleted information (table and index data) in
rollback segments, generates redo (keeps archiver busy), updates free lists for blocks that are
falling below PCTUSED setting etc..
Select count(*) runs longer because oracle scans all blocks (upto the High Water Mark) whether
there are or are not any rows in the blocks.
These operations will take more and more time, if the tables are loaded with APPEND hint or
SQL*Loader using direct mode.
A long time ago, I ran into a similar situation. Data was "deleted" selectively, SQL*Loader was
used (in DIRECT mode) to add new rows to the table. I had a few tables using more number of blocks
than the number of rows in the table!
Needless to say, the process was changed to truncate tables after exporting/extracting required
data first, and then loading the data back. Worked much better. -
I have question about dml mechanism. particularly delete statement
HI,
I have question about dml mechanism. particularly delete statement
I learned that SQL statements deal with each row. For example, SELECT statement insert each record(1 row) which matched with term of WHERE into record pool.
Also I find that UPDATE, INSERT statement insert each record into memory and if that is commited, I/O is generated with disk.
if so, Do DELETE statements deal with each row which is matched with terms WHERE statements? ortherwise with rownum?
I hope that I know the mechanism of DELETE statement?
If the content above which I mentioned is fault, plz point out.
Thank you for reading this contents.Hi,
leave_for wrote:
HI,
I have question about dml mechanism. particularly delete statement
I learned that SQL statements deal with each row. I'm not sure what you mean.
SQL statements deal with sets of rows ; there may be 0, 1, 2, 3 or more rows in the set.
For example, SELECT statement insert each record(1 row) which matched with term of WHERE into record pool.You must mean an INSERT or MERGE statement that includes a query. A plain old SELECT statement doesn't insert anything, or change any table in any way.
Also I find that UPDATE, INSERT statement insert each record into memory and if that is commited, I/O is generated with disk.That's right. All DML involves some I/O. The I/O may be buffered, so that the DML statement might finish before any disk I/O is actually performed.
if so, Do DELETE statements deal with each row which is matched with terms WHERE statements? ortherwise with rownum?
I hope that I know the mechanism of DELETE statement?Sorry; the last couple of lines you wrote are especially confusing.
When you have a DELETE statement that includes a WHERE clause, such as
DELETE emp
WHERE deptno = 20;then the set of rows that will be deleted is the same set of rows for which the condition "deptno = 20" is TRUE. Again, that may be 1 row, but if it is, that's mere coincidence. The number of rows in the set may be 0, or it may be 2 or more.
If ROWNUM is part of the WHERE clause, then ROWNUM will be considered when Oracle decides which rows to delete; if ROWNUM is not part of the WHERE clause, then ROWNUM will play no part in determining which rows are deleted. Remember, as Damorgan mentioned above, ROWNUM is an arbitrary number. There is no built-in order to the rows in any table. -
Prallel query and Delete statements
Hi Gurus, need your help in understanding parallel execution
We are noticing that delete statements are executing very slowly when parallel query is forced. Is this expected?
All the literature that I read says that parallel query has no impact on DML statements. Yet, the query plan on the delete statement shows that it will be executed in parallel mode. This could mean that the scan portion is happening in parallel but the delete operation itself is happening in serial, correct?
I tested in various servers and multiple tables before posting my question here. They all seem to show consistent results. Delete statements are twice slower when parallel query is forced. The same happens when parallel degree is set in table definition.
For your information, we are running 10g on windows server with 15 million rows in table, 5 million rows being deleted with the statement. There is one index on the table and it doesn’t match the columns in query. Query plan shows full table scan. Table is not portioned.
Thanks for your help in advanceParallel DML is supported by Oracle. Obviously when enabled, it can impact a DML statement.. (what literature have you read that said otherwise?)
The delete operation itself is done in parallel using rowid ranges (e.g. each PQ slave process does a distinct physical "piece" of the table).
Parallel DML should typically speed up the process. Why? Because I/O itself has latency. The process needs to wait (idle CPU time) for the I/O operation to complete before continuing.
So let's assume the process can only do a 100 deletes per second. The actual I/O channel is capable of a 1000 I/O's per second. But due to inherant latency, the "max delete speed limit" for a procces is a 100 I/O's per second. The full capacity of the I/O channel is thus not used (and cannot be used by a single process).
Parallel Query enables more processes to do I/O in order to utilise this "max speed limit".
Why would you see a degradation in performance? It could be due to overutilising the I/O channels (attempting to go faster than the speed limit so to say).
It could be due to some other contention in Oracle or even the o/s. You will need to investigate the wait state and events of the PQ processes to try and determine the probable cause. -
hi,
We have a performance issue the delete statements on the database are running very slow they are taking about 12 hours.
the delete statements are like
DELETE table_name
WHERE column1 = 'temp'
AND col2 LIKE 'A%'
AND col3 = 0;
that table has an composite index with 5 columns and the columns specified in the delete statements are in the order
column1 position 4
col2 position 3
col3 position 5
no additional indexes are present on the tableAs already suggested get an execution plan for the deletes to see what it is doing to make informed decisions about what to do.
Until then ...
You said you have one index on 5 columns
WHERE column1 = 'temp'
AND col2 LIKE 'A%'
AND col3 = 0;
that table has an composite index with 5 columns and the columns specified in the delete statements are in the order
column1 position 4
col2 position 3
col3 position 5Oracle might be doing a skip scan on the index or a full table scan - it is possible neither is efficient for your operation. An index ordered by # of unique values (most unique first) on column1, col2, col3 might help performance on this delete if a small percentage of rows are being deleted (anywhere from 5% to maybe 30%, it depends). If a large percentage of rows are being deleted then a full table scan might be better.
If you have the license and the database is set up for it parallel DML is a possiblity - check the on-line documentation to see how to do the delete in parallel. -
How Increase performance of delete operation
Hi,
How Increase performance of delete operation. This delete is done on a table which has around millions of records and loaded back every day .
The statement is in a procedure and is as follows.
#$%%$#$;
commit;
delete from TVRBC_SITE_ROLLUP_T;
commit;Hi,
execute immediate 'truncate table TVRBC_SITE_ROLLUP_T';
Regards,
Oleg
Message was edited by:
tsiboleg -
APP-PAY-07201 Cannot perform a delete when child record exists in future
I am trying to put end date to a payment method of any employee in HR/Payroll 11.5.10.2
but receiving the following error message:
APP-PAY-07201 Cannot perform a delete when child record exists in future
Can u advise what steps I should follow to resolve this issue.
Regards /AliThis note is related to termination of employee while our employee is on payroll and just want to change is payment method. But in the presence of existing payment method we cannot attched another becuase we are receiving an error:
APP-PAY-07041: Priority must be unique within an orgainzational payment method -
Missing privilege - DELETE statement in procedure
Hello experts,
I am facing a problem for my procedure. I am not able to active the procedure if I use DELETE statement in the produce. When I use only selects, it is working fine. The SYSTEM user has access to the schema with full rights, including DELETE.
PROCEDURE "SYSTEM"."DEV_COL.procedures::FI" ( )
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
DEFAULT SCHEMA UXX790
AS
BEGIN
Write your procedure logic
-- SELECT vbeln
--count(*)
DELETE
from vbapold
where erdat < ADD_days(now(), -1700);
END;
Did anybody had the same issue? I run HANA rev70.
BR
TamasHi Tamas
if this is a repository procedure user _SYS_REPO has to have the DELETE privilege with grant option as well.
- Lars
Maybe you are looking for
-
Retrieving User groups and email for all users in a group
Hi Everyone, I need to create an ADF application to retrieve all the groups in OID, the user would select a group and it should list down all the email addresses in that group. Can you suggest what is the best way to achieve this. My main concern is
-
PDF Thumbnails in Windows explorer...
I have noticed that when you choose thumbnail view in XP or Vista, it only shows a adbove icon instead of an actual pdf thumbnail of th actual document. When reviewing hundreds of PDF's in windows explorer, this is a necessity. Why was this a standar
-
"Waiting" under docs in iCloud
I use iCloud to store my Numbers and TextEdit documents. I have used only .22 GB of space so far. I have a several Numbers & TextEdit docs in the cloud of my MacBook Pro. The most recent docs have the word "waiting" underneath it. The docs open OK on
-
User Directory services stopped working
Getting this err all the sudden: The User Directory publishing service reported an error. https://server:8900/contribute Error details: End of file or no input:' Operations interrupted or timed out' Happens to everyone. using CPS 1.11 with ActiveDire
-
Having problems downloading trial of phohoshop for imac lion
I just cant seem to open the download assistant file, is Lion just not compatable?? Any help would be great!!