|
|
|
|
|
by masklinn
2244 days ago
|
|
> IF EXISTS for DDL operations It's a super convenient operation but it has one big drawback which might be unexpected: `if exists` first acquires the relevant lock then checks. This means a "ALTER TABLE table_name DROP COLUMN IF EXISTS column_name" will first acquire an ACCESS EXCLUSIVE lock, then check if the column exist. Since DDL is transactional the lock will not be released until the transaction is committed or rollbacked, therefore even if the column doesn't exist it will prevent all concurrent operations on the table. |
|