5

Is there a way to configure PostgreSQL so that when I run a "delete from table_a;" it outputs some information how many entries that was cascade deleted.

I'm running my querys in the cli application.

2 Answers 2

9

I found a solution. It was good enough for me, though I wanted a estimated statistics on how many rows that were effected.

This will ouput a list of all constraints triggered by the query.

EXPLAIN ANALYZE DELETE FROM table_a;
Sign up to request clarification or add additional context in comments.

Comments

0

You could use a plpgsql trigger function on tables to increment a sequence on a delete to get an exact count.

You would need to reset the sequence before issuing the delete. You could use a different sequence per table to get per table statistics.

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.