Killing and getting traceback

Asked by At

I have a database in PostgreSQL 10.7 and some of my queries are taking a very long time but I don't know what query it is, I know that there is a possibility to kill the process in the middle of it and get a trackback to figure out which query is taking so long. How can I achieve that?

UPDATE: basically in my App i push a button and it takes too long, so i just want to know what query is taking this much time

1 Answers

Community On Best Solutions

I hope the below hits the high points here. The below should give details as to what's up.

 create function python_version()
returns text
language plpythonu
as $$

import sys
import traceback

    return sys.version
    error = sys.exc_info()[0]
    details = traceback.format_exc()
    plpy.error('%s: %s' % ( error, details ) )