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

From: Tim Kane <TimK(at)blinkbox(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:35:29
Message-ID: CF8E878E.7568D%timk@blinkbox.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.

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?

Tim Kane
Senior Development Engineer Lead
t: +44 20 7092 8700
m:
blinkbox music - the easiest way to listen to the music you love, for free
www.blinkboxmusic.com

Browse pgsql-general by date

  From Date Subject
Next Message Tim Kane 2014-05-06 11:46:51 DDL statement blocked on long-running query with no runtime dependancy
Previous Message Hengky Liwandouw 2014-05-06 03:37:29 Re: Crosstab function