|
|
|
|
|
|
|
Re: Need performance tuning in delete statement [message #478785 is a reply to message #478784] |
Tue, 12 October 2010 09:47 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
create or replace
procedure show_space
( p_segname in varchar2,
p_owner in varchar2 default user,
p_type in varchar2 default 'TABLE' )
as
l_free_blks number;
l_total_blocks number;
l_total_bytes number;
l_unused_blocks number;
l_unused_bytes number;
l_LastUsedExtFileId number;
l_LastUsedExtBlockId number;
l_LAST_USED_BLOCK number;
procedure p( p_label in varchar2, p_num in number )
is
begin
dbms_output.put_line( rpad(p_label,40,'.') ||
p_num );
end;
begin
dbms_space.free_blocks
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
freelist_group_id => 0,
free_blks => l_free_blks );
dbms_space.unused_space
( segment_owner => p_owner,
segment_name => p_segname,
segment_type => p_type,
total_blocks => l_total_blocks,
total_bytes => l_total_bytes,
unused_blocks => l_unused_blocks,
unused_bytes => l_unused_bytes,
LAST_USED_EXTENT_FILE_ID => l_LastUsedExtFileId,
LAST_USED_EXTENT_BLOCK_ID => l_LastUsedExtBlockId,
LAST_USED_BLOCK => l_LAST_USED_BLOCK );
p( 'Free Blocks', l_free_blks );
p( 'Total Blocks', l_total_blocks );
p( 'Total Bytes', l_total_bytes );
p( 'Unused Blocks', l_unused_blocks );
p( 'Unused Bytes', l_unused_bytes );
p( 'Last Used Ext FileId', l_LastUsedExtFileId );
p( 'Last Used Ext BlockId', l_LastUsedExtBlockId );
p( 'Last Used Block', l_LAST_USED_BLOCK );
end;
/
CREATE procedure above then do below & post FORMATTED results
SQL> EXEC SHOW_SPACE('GL_ACCOUNT');
|
|
|
|
|
|
|
Re: Need performance tuning in delete statement [message #478795 is a reply to message #478773] |
Tue, 12 October 2010 10:39 |
sunroser
Messages: 16 Registered: September 2010
|
Junior Member |
|
|
burasami wrote on Tue, 12 October 2010 09:22Hi All,
I need to performance tune SQL statement as follows
DELETE FROM GL_ACCOUNT WHERE GL_ACCT_ID IN (SELECT GL.GL_ACCT_ID FROM GL_ACCOUNT GL WHERE GL.BU_ID !=609);
the above Statement taking long time to delete record.
for test purpose i try to delete 3 row its take much time to delete 3 records
here by i have attached TKPROF file. Please help me to fine the sql query. since for past 3 days trying to fine tune but i can't able to solve this issue.
Thanks & Regards
Sami
Something like the below .. ...
DELETE FROM GL_ACCOUNT GL
WHERE EXISTS (
SELECT NULL FROM GL_ACCOUNT GL1
WHERE GL.GL_ACCT_ID = GL1.GL_ACCT_ID
AND GL1.BU_ID != 609);
|
|
|
Re: Need performance tuning in delete statement [message #478866 is a reply to message #478773] |
Wed, 13 October 2010 01:53 |
michael_bialik
Messages: 621 Registered: July 2006
|
Senior Member |
|
|
Look at your TKPROF:
select /*+ all_rows */ count(1)
from
"OFFLINETESTDB"."GL_ACCOUNT_QUARTERLY_STAT" where "GL_ACCT_ID" = :1 and
"GL_ACCT_NO" = :2
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 3 0.00 0.06 0 0 0 0
Fetch 3 1.64 20.79 108398 109500 0 3
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 7 1.64 20.86 108398 109500 0 3
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS (recursive depth: 1)
Rows Row Source Operation
------- ---------------------------------------------------
3 SORT AGGREGATE (cr=109500 pr=108398 pw=0 time=20797344 us)
0 TABLE ACCESS FULL GL_ACCOUNT_QUARTERLY_STAT (cr=109500 pr=108398 pw=0 time=20797279 us)
********************************************************************************
select /*+ all_rows */ count(1)
from
"OFFLINETESTDB"."GL_ACCOUNT_MONTHLY_STAT" where "GL_ACCT_ID" = :1 and
"GL_ACCT_NO" = :2
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 4 0.00 0.06 0 0 1 0
Fetch 3 0.75 10.11 52140 59532 0 3
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 9 0.75 10.18 52140 59532 1 3
Misses in library cache during parse: 1
Misses in library cache during execute: 1
Parsing user id: SYS
Rows Row Source Operation
------- ---------------------------------------------------
3 SORT AGGREGATE (cr=59532 pr=52140 pw=0 time=10116280 us)
0 TABLE ACCESS FULL GL_ACCOUNT_MONTHLY_STAT (cr=59532 pr=52140 pw=0 time=10116221 us)
Both statements perform FULL table scan on GL_ACCOUNT_MONTHLY_STAT and GL_ACCOUNT_QUARTERLY_STAT tables (IMHO you have some trigger(s) attached that execute these statements).
I recommend:
CREATE INDEX ... ON GL_ACCOUNT_QUARTERLY_STAT ( GL_ACCT_ID, GL_ACCT_NO ) ...
CREATE INDEX ... ON GL_ACCOUNT_MONTHLY_STAT ( GL_ACCT_ID, GL_ACCT_NO ) ...
HTH.
Michael
[Updated on: Wed, 13 October 2010 01:55] Report message to a moderator
|
|
|
|