Can I execute a stored procedure 'detached' (not keeping DB connection open) on PostgreSQL? <p>I want to execute a long-running stored procedure on PostgreSQL 9.3. Our database server is (for the sake of this question) guaranteed to be running stable, but the machine calling the stored procedure can be shut down at any second (Heroku dynos get cycled every 24h).</p> <p>Is there a way to run the stored procedure 'detached' on PostgreSQL? I do not care about its output. Can I run it asynchronously and then let the database server keep working on it while I close my database connection?</p> <p>We're using Python and the <a href="http://initd.org/psycopg/docs/" rel="nofollow">psycopg2 driver</a>, but I don't care so much about the implementation itself. If the possibility exists, I can figure out how to call it.</p> <p>I found notes on the <a href="http://initd.org/psycopg/docs/advanced.html#async-support" rel="nofollow">asynchronous support</a> and the <a href="http://aiopg.readthedocs.org/en/0.3/index.html" rel="nofollow">aiopg library</a> and I'm wondering if there's something in those I could possibly use.</p>