pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andreas Joseph Krogh <andreas@visena.com>
To: DrakoRod <drakoflames@hotmail.com>
Cc: pgsql-general@postgresql.org
Subject: Sv: DELETE Query Hang
Date: Wed, 13 Nov 2019 00:20:36 +0100 (CET)
Message-ID: <VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena> (raw)
In-Reply-To: <1573598838391-0.post@n3.nabble.com>


På tirsdag 12. november 2019 kl. 23:47:18, skrev DrakoRod <
drakoflames@hotmail.com <mailto:drakoflames@hotmail.com>>: 
Hi folks!

 I Have a question, in a database are a table with many files (bytea) stored
 (I support this database a don't design it), but we need delete many rows
 (38000 rows approx), but I when execute query:

 BEGIN;
 ALTER TABLE my_file_table DISABLE TRIGGER ALL;
 DELETE FROM my_file_table WHERE id_table <> 230;

 This query hang... 50 minutes and the query do not finish.

 Any suggestion? 

Check for locks and blocking statements: 
https://wiki.postgresql.org/wiki/Lock_Monitoring 
<https://wiki.postgresql.org/wiki/Lock_Monitoring; 

You can delete in chunks like this: 

do $_$ declare num_rows bigint; begin  loop  delete from YourTable where id in 
(select id from YourTable where id < 500 limit 100); get diagnostics num_rows = 
row_count; raise notice 'deleted % rows', num_rows; exit when num_rows = 0; end 
loop; end;$_$; 


--
 Andreas Joseph Krogh 

Message-ID: <VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena>
Permalink:  ../VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena/
Also on:    postgresql.org/message-id/VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: andreas@visena.com, drakoflames@hotmail.com
  Subject: Re: DELETE Query Hang
  In-Reply-To: <VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena>
  References: <1573598838391-0.post@n3.nabble.com> <VisenaEmail.56.c3b346f6a24e6ccf.16e61e9df08@tc7-visena>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox