DDL statement blocked on long-running query with no runtime dependancy

From: Tim Kane <tim(dot)kane(at)gmail(dot)com>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: DDL statement blocked on long-running query with no runtime dependancy
Date: 2014-05-06 11:46:51
Message-ID: CF8E8A3B.756DB%tim.kane@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

I’ve just noticed that some DDL statements will block if there are other
queries accessing the relation in question, even where those queries are not
dependant on the underlying structures (such as a new index, created after
the initial query).

For instance…

> SELECT long_running_query FROM foo; -- Query A,
>
> -- meanwhile…
>
> CREATE UNIQUE INDEX ON foo USING btree (blah);
> -- Fine, no problem
>
> DROP INDEX foo_blah_idx;
> -- The above DDL statement will block until Query A completes, even though the
> query cannot possibly rely on the newly created index
>

Is this behaviour by design? Is it worth allowing DDL statements to occur
where it can be determined that no currently running query will be affected?

Cheers,

Tim

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marcus Engene 2014-05-06 12:52:34 copy expensive local view to an RDS instance
Previous Message Tim Kane 2014-05-06 11:35:29 DDL statement blocked on long-running query with no runtime dependancy