# Locking and performance

Row-level locking improves concurrency in a multi-user system. However, a large number of row locks can degrade performance.

About the system's selection of lock granularity discussed the way the optimizer makes some compile-time decisions about escalating row locks to table locks for performance reasons. This section discusses ways in which the Derby system and the user can make similar lock escalations.

- Transaction-based lock escalation
  The optimizer makes its decisions for the scope of a single statement at compile time; the runtime overrides are also for the scope of a single statement.
- Locking a table for the duration of a transaction
  You can explicitly lock a table for the duration of a transaction with the LOCK TABLE statement.

Parent topic: DML statements and performance
Related concepts
Performance and optimization
Non-cost-based optimizations
Overriding the default optimizer behavior