Home » RDBMS Server » Performance Tuning » Reg Segment advisor (Oracle 10g)
Reg Segment advisor [message #515396] Mon, 11 July 2011 06:28 Go to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

Hi All,

I understand from oracle 10g, to reclaim the wasted space of a segment, we can do a segment level shrink in online through the following way.

--Enable Row Movement.
ALTER TABLE scott.emp ENABLE ROW MOVEMENT;

-- Recover space and amend the high water mark (HWM).
ALTER TABLE scott.emp SHRINK SPACE;

-- Recover space, but don't amend the high water mark (HWM).
ALTER TABLE scott.emp SHRINK SPACE COMPACT;

Now My concern is, when any package,procedure,functions or cursors are refering this emp table, can we fire the below command to enable the row movement of that table?

--Enable Row Movement.
ALTER TABLE scott.emp ENABLE ROW MOVEMENT;

As per my knowledge, it is a DDL statement and if we fire a DDL statement when package or cursor accessing this table, the package or cursor will be getting as INVALID.

Then how oracle saying as we can do this activity in online.

I cannot able to understand. Pls correct me if I am wrong.
Re: Reg Segment advisor [message #515403 is a reply to message #515396] Mon, 11 July 2011 06:50 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Then how oracle saying as we can do this activity in online.

Because invalidating something does not mean it can't run.
The DDL can't run if the package or cursor is currently executing.
Once the DDL started to run, Oracle can (most often) manage the package and cursor to make them execute (but on some very specific part).
But this can lead to some error message like "invalid rowid" or "existing state of packages has been discarded", this is why you must not "reorganize" without a good reason and do it during low workload window.

Regards
Michel

Re: Reg Segment advisor [message #515412 is a reply to message #515403] Mon, 11 July 2011 07:45 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member
Thanks for your response.

So altimately can I take your answer as, executing shrink space statement during online will bring u in risk side at some time?
(Or)
To avoid risk 100%,we need to execute this shrink space statement after declaring outage for that particular table?



Re: Reg Segment advisor [message #515417 is a reply to message #515412] Mon, 11 July 2011 08:05 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
So altimately can I take your answer as, executing shrink space statement during online will bring u in risk side at some time?

Yes

Quote:
To avoid risk 100%,we need to execute this shrink space statement after declaring outage for that particular table?

It is not mandatory but better (if you don't want an unexpected outage).

But the question remains: "do you really need to shrink space?"

Regards
Michel

[Updated on: Mon, 11 July 2011 08:06]

Report message to a moderator

Re: Reg Segment advisor [message #515528 is a reply to message #515417] Tue, 12 July 2011 02:18 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

yes. Every week I am doing defragmentation activity for 10 to 15 tables by using alter table move.
To avoid the outage, thought of approching shrink space way. but now I understood, alter table move is best instead shrink space,since it is faster and also both way requires outage.

Can I have any best way than this, if exist?
Re: Reg Segment advisor [message #515529 is a reply to message #515528] Tue, 12 July 2011 02:26 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Every week I am doing defragmentation activity for 10 to 15 tables

Why?

Regards
Michel
Re: Reg Segment advisor [message #515530 is a reply to message #515396] Tue, 12 July 2011 02:28 Go to previous messageGo to next message
hkchital
Messages: 128
Registered: September 2008
Location: Singapore
Senior Member
>if we fire a DDL statement when package or cursor accessing this table, the package or cursor will be getting as INVALID.
>Then how oracle saying as we can do this activity in online.

Because the package, cursor etc will be recompiled/reparsed at the next call.

Also remember that you need to ENABLE ROW MOVEMENT only *once* in the lifetime of a table. If you are shrinking the table every week (I wonder if you really need to do this every week), you don't have to ENABLE ROW MOVEMENT every week ! It is a table attribute, once set always present (unless you drop and recreate the table).


Hemant K Chitale
Re: Reg Segment advisor [message #515532 is a reply to message #515529] Tue, 12 July 2011 02:32 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

because those tables are having heavy DML's. that we can't avoid. And the project currently not willing to add storage in that box.

Re: Reg Segment advisor [message #515535 is a reply to message #515532] Tue, 12 July 2011 02:39 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member
Hi hemant,

Thanks for your response.

I agree all your points.

But If we keep the row movement enabled, the performance of the queries accessing that table will be getting degraded. So we can't keep the row movement enabled all the time.

Pls correct me if am wrong

Re: Reg Segment advisor [message #515536 is a reply to message #515535] Tue, 12 July 2011 02:50 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
the performance of the queries accessing that table will be getting degraded.

What make you think that?

Quote:
because those tables are having heavy DML's. that we can't avoid

What make you think that you can't avoid it?

Regards
Michel
Re: Reg Segment advisor [message #515537 is a reply to message #515535] Tue, 12 July 2011 02:51 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Quote:
But If we keep the row movement enabled, the performance of the queries accessing that table will be getting degraded.
Hi - please can you explain why you say this? I haven't yet attempted to falsify your hypothesis, but I cannot see why enabling row movement would have any bad effect.
Re: Reg Segment advisor [message #515584 is a reply to message #515537] Tue, 12 July 2011 05:01 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

Quote:
Hi - please can you explain why you say this? I haven't yet attempted to falsify your hypothesis, but I cannot see why enabling row movement would have any bad effect.


"enable row movement" can cause Oracle to move rows to discontinuous data blocks. so the order of the index entry or blocks will be getting changed causes clustering factor value to high than previous causing excessive I/O.

Re: Reg Segment advisor [message #515586 is a reply to message #515584] Tue, 12 July 2011 05:06 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

because those tables are having heavy DML's. that we can't avoid

Quote:
What make you think that you can't avoid it?


we are getting high number of inserts and deletes on this table. The application design is as such. we cannot think of changing the application design just because of avoiding fragmentaion. Thats why I said as, we cannot avoid.
Re: Reg Segment advisor [message #515587 is a reply to message #515584] Tue, 12 July 2011 05:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
"enable row movement" can cause Oracle to move rows to discontinuous data blocks.

This is totally wrong, Oracle does not move rows unless you tell it to do so (with an ALTER TABLE for instance).

Quote:
so the order of the index entry or blocks will be getting changed

Where did you see that? The position of a row in an index is determined by the value of the index columns for this row not by its rowid.

Regards
Michel

[Updated on: Tue, 12 July 2011 05:12]

Report message to a moderator

Re: Reg Segment advisor [message #515589 is a reply to message #515584] Tue, 12 July 2011 05:09 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
No, you have misunderstood this. Enabling row movement means that Oracle will permit operations that cause rowids to change. These operations can include SHRINK SPACE, and DML on partition key columns. It doesn't cause anything - it merely makes things possible.
Re: Reg Segment advisor [message #515592 is a reply to message #515589] Tue, 12 July 2011 05:13 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

But after shrinking the space, the order of the rowid will be getting changed. In that case, the query performance will be getting degraded. Am I right or wrong?

I think in that case, we need to rebuild the index to order the index entries. pls correct me if I am wrong.
Re: Reg Segment advisor [message #515593 is a reply to message #515592] Tue, 12 July 2011 05:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
But after shrinking the space, the order of the rowid will be getting changed. In that case, the query performance will be getting degraded. Am I right or wrong?

So why do you shrink?
This is wrong, it may be better, it may worse, it may not change, this is one of the reason we asked "Why do you do that?".

Quote:
I think in that case, we need to rebuild the index to order the index entries

See my previous answer.
The property of an index is to have its entries sorted otherwise it is (most often) useless.

Regards
Michel
Re: Reg Segment advisor [message #515596 is a reply to message #515592] Tue, 12 July 2011 05:34 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
A table shrink operation is, in effect, a series of insert/delete/commit statements: the end result is that rows are relocated, as far as possible, towards the first blocks of the segment. The clever part is that insert and delete triggers do not fire. Indexes are maintained. Following this DML phase (which may take a long time) the high water mark of the segment is brought down, in order to release the free space (this step is virtually instantaneous). So, to revert to your original question, this operation is "online", except for individual row locks as the rows are moved, and a table lock when the high water mark is adjusted.
As Michel says, you need to be clear on why you want to do this. I can see no benefit, unless the number of rows in the table is continually reducing. If it is constant or increasing, there is no point.
Re: Reg Segment advisor [message #515597 is a reply to message #515593] Tue, 12 July 2011 05:40 Go to previous messageGo to next message
sathik
Messages: 196
Registered: August 2009
Location: INDIA
Senior Member

Still I can't able to understand the things. because I saw this link that "BEWARE: Enable row movement can cause performance problems"

http://www.dba-oracle.com/t_enable_row_movement.htm

Re: Reg Segment advisor [message #515602 is a reply to message #515597] Tue, 12 July 2011 05:59 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
NEVER trust what you find on this site.
REMOVE it from your searches.
This site is a b...

Regards
Michel
Re: Reg Segment advisor [message #515632 is a reply to message #515597] Tue, 12 July 2011 09:58 Go to previous message
hkchital
Messages: 128
Registered: September 2008
Location: Singapore
Senior Member
The "ENABLE ROW MOVEMENT" per se doesn't cause the "performance issue" that Burleson describes.
It is actually the ALTER TABLE SHRINK SPACE that can change the Clustering Factor of indexes --- so it is the DBA who "causes the issue" !

ENABLE ROW MOVEMENT is also necessary to "allow" moving a Row from one Partition to another Partition in a Partitioned Table.
See http://hemantoracledba.blogspot.com/2011/07/enable-row-movement.html


Hemant K Chitale
Previous Topic: Sol req : Alternative way of rewriting the query
Next Topic: Help SQL Tuning
Goto Forum:
  


Current Time: Wed Apr 24 18:15:09 CDT 2024