SKIP LOCKED
Skip rows that are currently locked by another transaction, enabling efficient job queue patterns.
SKIP LOCKED SKIP LOCKED DATA READPAST queue pattern
locking concurrency queue job queue skip
| Database | Status | Syntax Family | Min Version |
|---|---|---|---|
| PostgreSQL | full | skip-locked | 9.5 |
| MySQL | full | skip-locked | 8.0 |
| MariaDB | full | skip-locked | 10.6 |
| Oracle | full | skip-locked | 11g |
| SQL Server | partial | readpast-hint | - |
| SQLite | none | - | - |
| Redshift | none | - | - |
| DB2 | full | skip-locked-data | - |
| Snowflake | none | - | - |
| BigQuery | none | - | - |
Compare Databases
Database Details
PostgreSQL
full
SELECT id, payload FROM jobs WHERE status = 'pending' ORDER BY id LIMIT 10 FOR UPDATE SKIP LOCKED;- Available as a modifier to FOR UPDATE and FOR SHARE.
- Rows locked by other transactions are silently omitted from the result set.
- Ideal for implementing concurrent job queues.
MySQL
full
SELECT id, payload FROM jobs WHERE status = 'pending' ORDER BY id LIMIT 10 FOR UPDATE SKIP LOCKED;- Added in MySQL 8.0.
- Available as a modifier to FOR UPDATE and FOR SHARE.
- Locked rows are excluded from the result set without raising an error.
MariaDB
full
SELECT id, payload FROM jobs WHERE status = 'pending' ORDER BY id LIMIT 10 FOR UPDATE SKIP LOCKED;- Added in MariaDB 10.6.
- Available as a modifier to FOR UPDATE.
- Locked rows are silently skipped in the result.
Oracle
full
SELECT id, payload FROM jobs WHERE status = 'pending' AND ROWNUM <= 10 FOR UPDATE SKIP LOCKED;- Available since Oracle 11g Release 1.
- Rows locked by other sessions are excluded from the result set.
- ROWNUM is typically used for limiting rows in lieu of LIMIT/FETCH FIRST.
SQL Server
partial
SELECT TOP 10 id, payload FROM jobs WITH (UPDLOCK, READPAST) WHERE status = 'pending' ORDER BY id;- Uses the READPAST table hint instead of the SQL standard SKIP LOCKED clause.
- READPAST only skips rows locked with exclusive locks; share-locked rows are not skipped.
- Combine with UPDLOCK to acquire an update lock on the returned rows.
Docs: Table Hints: READPAST
SQLite
none
- SQLite has no row-level locking and therefore no SKIP LOCKED mechanism.
- Concurrency is managed at the database or WAL-segment level.
Redshift
none
- Redshift uses MVCC with no row-level locking, so SKIP LOCKED has no equivalent.
DB2
full
SELECT id, payload FROM jobs WHERE status = 'pending' FETCH FIRST 10 ROWS ONLY FOR UPDATE SKIP LOCKED DATA;- Uses the SKIP LOCKED DATA clause rather than the shorter SKIP LOCKED form.
- Locked rows are excluded from the result without raising a lock timeout error.
- Available for cursors declared with FOR UPDATE.
Docs: SELECT: SKIP LOCKED DATA
Snowflake
none
- Snowflake uses optimistic concurrency control with no row-level locks.
- SKIP LOCKED has no equivalent.
Docs: Snowflake Transactions
BigQuery
none
- BigQuery does not support row-level locking or SKIP LOCKED.
Docs: BigQuery Transactions