Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the impact of enabling/disabling ROW_MOVEMENT in Oracle 10g?

We are using oracle 10G and one of the table takes lot of time if we query/delete data. This table contains around 10 million records.

Recently we discovered that ROW_MOVEMENT is disabled on this table, we want to understand following:

  1. What performance gain we can get if enable ROW_MOVEMENT ?
  2. Are there any downsides of enabling ROW_MOVEMENT ?
  3. What trigger's row movement ? How does oracle decides it needs to move ROWS ?

Any help would be highly appreciated.

Thanks in advance !!

like image 957
Sachin Thapa Avatar asked Oct 17 '13 14:10

Sachin Thapa


People also ask

What does enable row movement mean?

enable row movement in 9i The row_movement_clause lets you specify whether Oracle can move a table row. It is possible for a row to move, for example, during data segment compression or an update operation on partitioned data.

Why enable row movement in Oracle?

When you add the clause "enable row movement" to a create table statement, you are giving Oracle permission to change the ROWID's. This allows Oracle to condense table rows and make it easier to reorganize tables.

How do you turn off row movement in Oracle?

If the table has row movement disabled, why is it you can drop the table and flashback the table to before the drop without row movement being enabled? SQL> ALTER TABLE CITY_OFFICES DISABLE ROW MOVEMENT; Table altered.

How do you check row movement is enabled or not?

You can check if row movement is already enabled by querying the ROW_MOVEMENT column of the [DBA|ALL|USER]_TABLES views. Row movement is enabled with the following command. ALTER TABLE emp ENABLE ROW MOVEMENT; Repeating the previous query shows row movement is now enabled.


2 Answers

Row movement is mainly applied to partition tables. It allows rows to be moved across partitions. With row movement disabled, which is the default, you can't move a row with an update:

SQL> CREATE TABLE part_table (ID NUMBER)
  2  PARTITION BY RANGE (ID)
  3     (PARTITION p0 VALUES LESS THAN (1),
  4      PARTITION p1 VALUES LESS THAN (MAXVALUE));

Table created

SQL> INSERT INTO part_table VALUES (0);

1 row inserted

SQL> UPDATE part_table SET ID = 2;

UPDATE part_table SET ID = 2

ORA-14402: updating partition key column would cause a partition change

When you allow row movement, you can move rows with an update:

SQL> ALTER TABLE part_table ENABLE ROW MOVEMENT;

Table altered

SQL> UPDATE part_table SET ID = 2;

1 row updated

This feature doesn't affect performance in most cases: the rows are stored and queried in exactly the same manner whether the feature is enabled or not. However, when row movement is enabled, the rows can be physically moved (similar to delete+insert) with ALTER TABLE SHRINK SPACE for example. This may in turn affect index cluster factor for instance, which may affect the performance of some queries.

Row movement is disabled by default because it implies that the rowid of a row may change, which is not the usual behaviour in Oracle.

like image 189
Vincent Malgrat Avatar answered Sep 24 '22 02:09

Vincent Malgrat


Downside of row movement is that ROWIDs may be changed. So if you have any queries based on ROWID they may return wrong results

like image 38
Kacper Avatar answered Sep 25 '22 02:09

Kacper