Schema:

ACCOUNT_USAGE

LOCK_WAIT_HISTORY View

This Account Usage view includes the history of transactions that wait on locks. For details, see Analyzing Blocked Transactions with the LOCK_WAIT_HISTORY View.

Columns

Column Name

Data Type

Description

OBJECT_ID

NUMBER

Internal/system-generated identifier for the object (e.g. table) on which the transaction is waiting for a lock.

LOCK_TYPE

TEXT

Type of lock. Valid values are PARTITION, STREAM, and TABLE.

OBJECT_NAME

TEXT

Identifier for the object (e.g. table) on which the transaction is waiting for a lock.

SCHEMA_ID

NUMBER

Internal/system-generated identifier for the schema of the object on which the transaction is waiting for a lock.

SCHEMA_NAME

TEXT

Identifier for the schema of the object on which the transaction is waiting for a lock.

DATABASE_ID

NUMBER

Internal/system-generated identifier for the database of the object on which the transaction is waiting for a lock.

DATABASE_NAME

TEXT

Identifier for the database of the object on which the transaction is waiting for a lock.

QUERY_ID

TEXT

Internal/system-generated identifier for the SQL statement that is waiting on the lock.

TRANSACTION_ID

NUMBER

Internal/system-generated identifier for the transaction with the statement that is waiting on the lock. See Transaction ID.

REQUESTED_AT

TIMESTAMP_LTZ

Timestamp when the lock was requested by the transaction waiting for the lock.

ACQUIRED_AT

TIMESTAMP_LTZ

Timestamp when the lock was acquired by the transaction holding the lock.

BLOCKER_QUERIES

VARIANT

JSON array of objects. Each object is a blocker query with the following properties: . - query_id: Query ID of the current statement in the blocker transaction that blocked the statement. . - transaction_id: ID of the blocker transaction. . . There may be up to 20 objects in this array.

Usage Notes

  • The first blocker query ID that is returned in the blocker_queries array is the ID of the query that was being executed in the transaction that holds the lock when the transaction waiting for the lock started waiting. Note that it is possible that queries prior to that query in the blocker transaction also acquired the lock and should be investigated.

  • Each row in the output represents a transaction waiting on a lock. Note that there may be other transactions ahead of it waiting on the same lock.

Examples

Find all the blocked transactions that requested locks within the past 24 hours:

SELECT query_id, object_name, transaction_id, blocker_queries
  FROM snowflake.account_usage.lock_wait_history
  WHERE requested_at >= dateadd('hours', -24, current_timestamp());

For additional examples, see Analyzing Blocked Transactions with the LOCK_WAIT_HISTORY View.

Back to top