您的位置:首页 > 数据库

最小化表锁以优化数据库性能Minimizing Table Locks to Optimize Performance

2008-04-26 18:10 537 查看

最小化表锁以优化数据库性能

inserts, deletes, and updates 需要获理tm表级锁,将损耗性能,
注意如果将表级锁设为无效,将无法执行DDL操作,如修改表和索引等
设置表级锁无效的方法
方法一

设置数据库实例的DML_LOCKS 为零

注意把一个实例的dml_locks设为零,那在其它所有用到的实例也得设为零。
方法二
将表的表级锁设为无效
ALTER TABLE table_name DISABLE TABLE LOCK
将表锁设为有效的语句
ALTER TABLE table_name ENABLE TABLE LOCK
通过访问
USER_TABLES,DBA_TABLES 或 ALL_TABLES  就可以生成所有表的语句。

http://lbdwww.epfl.ch/f/teaching/courses/oracle8i/server.815/a67778/ch16_alr.htm#1334

Minimizing Table Locks to Optimize Performance

This section describes two strategies for improving performance by minimizing table locks:

Setting DML_LOCKS to Zero

Disabling Table Locks

Obtaining table locks (DML locks) for inserts, deletes, and updates can hurt performance in OPS. Locking a table in OPS is very undesirable because all instances holding locks on the table must release those locks. Consider disabling these locks entirely.


[b][b]Note:[/b]
If you use either of these strategies, you cannot perform DDL commands against either the instance or the table.

[/b]

Setting DML_LOCKS to Zero

Table locks are set with the initialization parameter DML_LOCKS. If the DROP TABLE, CREATE INDEX, and LOCK TABLE commands are not needed, set DML_LOCKS to zero to minimize lock conversions and gain maximum performance.


[b][b]Note:[/b]
If DML_LOCKS is set to zero on one instance, it must be set to zero on all instances. With other values, this parameter need not be identical on all instances.

[/b]

Disabling Table Locks

To prevent users from acquiring table locks, use the following command:
ALTER TABLE table_name DISABLE TABLE LOCK


Users attempting to lock a table when its table lock is disabled will receive an error.

To re-enable table locking, use the following command:
ALTER TABLE table_name ENABLE TABLE LOCK


The above command waits until all currently executing transactions commit before enabling the table lock. The command does not need to wait for new transactions starting after issuing the ENABLE command.

To determine whether a table has its table lock enabled or disabled, query the column TABLE_LOCK in the data dictionary table USER_TABLES. If you have select privilege on DBA_TABLES or ALL_TABLES, you can query the table lock state of other users tables.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: