I understand that views are implemented using the rule system but I'm unclear if this has any advantages/disadvantages when running transactional DDL against them. Does issuing CREATE OR REPLACE VIEW ...; or DROP VIEW ...; CREATE VIEW...; in a transaction take out an ACCESS EXCLUSIVE lock similar to DDL against a table? Would all queries issued before the DDL have to complete before the DDL could execute? Would queries issued after the DDL block until the DDL is complete?


Direct answers to your three questions would be;

  1. Yes it does. When you replace your view, the lock of view object will be AccessExclusiveLock.

  2. Yes, even the 'select' queries that uses that specific view will wait until the 'create or replace' statement is committed.

  3. Yes they do. After the "view changer" query is committed the queries that are waiting will start

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.