最小化表锁以优化数据库性能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. |
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. |
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.
相关文章推荐
- [Java Performance] 数据库性能最佳实践 - JPA和读写优化
- Related to Oracle 面向程序员的数据库访问性能优化法则(转)
- SAP HANA 数据库性能优化(SAP HANA DataBase Performance Tuning)
- [Java Performance] 数据库性能最佳实践 - JPA和读写优化
- [Java Performance] 数据库性能最佳实践 - JPA和读写优化
- MySQL 数据库性能优化之数据库配置优化
- TableView的性能优化-主要针对滑动时候出现的卡顿现象
- 优化TableView性能
- 优化数据库大幅度提高Oracle的性能
- 一次数据库的简单性能优化
- 数据库性能优化策略
- TableView性能优化——动态cell适应工具(UITableView+FDTemplateLayoutCell)
- 数据库性能优化和调整
- MySQL 数据库性能优化之索引优化(这是 MySQL数据库性能优化专题 系列的第三篇文章)
- 数据库性能优化策略
- 数据库性能优化
- 抽丝剥茧数据库访问性能优化
- LBS中从数据库查询某经纬度2KM范围内的数据 - 针对大数据量的性能优化
- MySQL 数据库性能优化之缓存参数优化
- MySQL 数据库性能优化之SQL优化