I have a regular case where I run many Postgres queries within a do/begin/end block

DO $$
END $$;

In some cases, the databases and queries run a little bit slow and we need visibility to estimate how long the transaction will take and see any problems along the way.

Does there exist a build in postgres way to see which individual query within the transaction is being executed?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Apr 14 at 4:40

1 Answer 1


The only thing that comes to my mind is to run something like this before each query:

RAISE NOTICE 'Now executing query number 42';

Such messages are reported to the client immediately.

  • This is a perfect solution for our case. Thank you
    – Hendy
    Apr 18 at 3:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.