> [!NOTE] LockRows
> <table>
> <tr>
> <td width="25%"><img src="assets/ex_lockrows.png"></td>
> <td>Implements <code>FOR UPDATE</code> or <code>FOR SHARE</code> locking. This node ensures that the rows returned by the query are locked against concurrent modification until the current transaction commits or rolls back.</td>
> </tr>
> </table>
>
> ```sql
> -- Locking a specific row for modification
> EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE)
> SELECT * FROM animals WHERE id = 1 FOR UPDATE;
> ```
>
> ```text
> LockRows (cost=1.29..9.31 rows=1 width=33) (actual time=1.017..1.017 rows=1 loops=1)
> Output: id, name, species_id, created_at, ctid
> Buffers: shared hit=5 dirtied=1
> -> Index Scan using animals_pkey on public.animals (...)
> ```
>
> <table>
> <tr>
> <td rowspan="5" width="25%"><img src="assets/ex_lock_rows.svg"></td>
> <td><b>Performance</b></td><td>Introduces overhead for lock acquisition and can lead to transaction blocking if other sessions held conflicting locks.</td>
> </tr>
> <tr><td><b>Factors</b></td><td>Number of rows locked and the degree of lock contention.</td></tr>
> <tr><td><b>Cost</b></td><td><code>lock acquisition cost * number of rows</code></td></tr>
> <tr><td><b>Operates on</b></td><td><a href="Structures/Tuple">Tuple</a></td></tr>
> <tr><td><b>Workloads</b></td><td><a href="Workloads/Lock/Lock/Lock_Tuple">Lock: Tuple</a>, <a href="Workloads/Lock/Lock/Lock_TransactionId">Lock: TransactionId</a>, <a href="Workloads/LWLock/Lock/LockManager">LWLock: LockManager</a>, <a href="Workloads/IPC/Snapshot/SafeSnapshot">IPC: SafeSnapshot</a></td></tr>
> <tr><td colspan="3"><b>Description</b>: Locks rows without changing them.</td></tr>
> </table>