Re: Fast way to delete big table? - Mailing list pgsql-general

From Jeff Janes
Subject Re: Fast way to delete big table?
Date
Msg-id CAMkU=1zYuHBwRiFnjYuufANZXv9Qh62XEnqg-EmbiurvHVGqkQ@mail.gmail.com
Whole thread Raw
In response to Re: Fast way to delete big table?  (hmzha2 <Haiming.Zhang@redflex.com.au>)
Responses Re: Fast way to delete big table?  (hmzha2 <Haiming.Zhang@redflex.com.au>)
List pgsql-general
On Mon, May 16, 2016 at 10:22 PM, hmzha2 <Haiming.Zhang@redflex.com.au> wrote:


> Works ok in my testing environment but not
> on the production machine. Select * from tableA limit 1; takes milliseconds
> to finish update summary table from the previous select result, takes
> milliseconds delete from tableA where primaryKey = ... takes 2.9 hours to
> finish.

Perhaps you have a foreign constraint pointing to your tableA from
another table, and the other table is un-indexed on those columns (in
production).  So every delete from tableA leads to a full scan of that
other table to make sure no offending rows exist.

If that is not the case, then I'd try to do a "strace -ttt -T -y -p
<PID>" on the process which is taking so long, and see what it is
doing.  Unfortunately, you have to do that on production, as that is
the only system where the problem appears.

Cheers,

Jeff


pgsql-general by date:

Previous
From: "Charles Clavadetscher"
Date:
Subject: Re: Fast way to delete big table?
Next
From: hmzha2
Date:
Subject: Re: Fast way to delete big table?