Re: DDL commands take forever

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: l(dot)rame(at)griensu(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: DDL commands take forever
Date: 2009-12-29 16:20:43
Message-ID: 20091229112043.f0ee5f49.wmoran@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

In response to "Leonardo M." Ramé <l(dot)rame(at)griensu(dot)com>:

> Hi, I need to create a trigger on a table used by our sofware, the
> problem is, when I issue a "create trigger...." on this table, it takes
> forever. It doesn't matter if I use pgAdmin, or psql.
>
> The only way to do it is by disconnecting all the instances of the
> program from the database, execute the DDL command, and reconnect the
> program again.
>
> What can be causing this behavior? any workaround?.

Most likely those programs have locks out that are causing the DDL command
to have to wait until the locks clear.

Disconnecting everyone is the quick workaround.

The real fix is to ensure that your application doesn't hold onto DB locks
longer than is needed, which won't guarantee that everything moves fast,
but will help immensely. Often this is caused by the application holding
transactions open for long periods of time, which is a bad idea anyway
since it interferes with vacuum and other maintenance operations.

You can look at the pg_locks table to see what locks are out, to help you
diagnose what apps are holding locks open.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message akp geek 2009-12-29 16:43:58 Comparing 2 databases
Previous Message Leonardo M. Ramé 2009-12-29 15:58:30 DDL commands take forever