Re: LONG delete with LOTS of FK's

From: Shaun Thomas <sthomas(at)optionshouse(dot)com>
To: Larry Rosenman <ler(at)lerctr(dot)org>
Cc: <pgsql-general(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: LONG delete with LOTS of FK's
Date: 2013-05-09 21:26:49
Message-ID: 518C1499.6050307@optionshouse.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/09/2013 04:22 PM, Larry Rosenman wrote:

> It's been on various tables, and they are all bigints.

Hey, ya never know. I've gotten tripped up similarly. In that case, I
defer to Tom's suggestion. If there are any '<IDLE> in transaction'
statements, or your long delete is marked as waiting in
pg_stat_activity, something is up. I've also found this query extremely
helpful in tracking down things like this:

SELECT DISTINCT l1.pid AS blocker_pid, a.current_query AS blocker_query,
a.usename AS blocker_user, a.client_addr AS blocker_client,
l2.pid AS blocked_pid, a2.current_query AS blocked_query,
a2.usename AS blocked_user, a2.client_addr AS blocked_client
FROM pg_locks l1
JOIN pg_stat_activity() a on (a.procpid = l1.pid)
JOIN pg_locks l2 ON (l1.relation = l2.relation AND l1.pid != l2.pid)
JOIN pg_stat_activity() a2 on (a2.procpid = l2.pid)
WHERE l1.granted
AND NOT l2.granted;

--
Shaun Thomas
OptionsHouse | 141 W. Jackson Blvd. | Suite 500 | Chicago IL, 60604
312-676-8870
sthomas(at)optionshouse(dot)com

______________________________________________

See http://www.peak6.com/email_disclaimer/ for terms and conditions related to this email

--
Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2013-05-09 21:29:02 Re: Re: [GENERAL] pg_upgrade fails, "mismatch of relation OID" - 9.1.9 to 9.2.4
Previous Message Larry Rosenman 2013-05-09 21:23:07 Re: LONG delete with LOTS of FK's