0

Looking for some help to run below delete in another way as below is long running.

delete from dbo.customer 
where ac_no not in (select ac_no from dbo.account)
2
  • Maybe it's waiting for a lock? Commented Jun 5, 2020 at 6:08
  • A delete trigger may also be the problem. For big update statements you may want to temporarily disable for-row triggers. Commented Jun 5, 2020 at 7:23

1 Answer 1

1

Perhaps PostgreSQL can optimize a NOT EXISTS clause better:

DELETE FROM dbo.customer
WHERE NOT EXISTS (SELECT 1 FROM dbo.account
                  WHERE customer.ac_no = account.ac_no);

But without seeing EXPLAIN output it is hard to say.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.