I tried to create tables, but it was useless because each begin-end block wrapped in transaction in postgres, so I can’t see any changes before the end of transaction.
The only solution is rising INFO, I use it to show current step of procedure, but its not exactly what I am looking for. I need to know detailed data of current calculations, because every step can take a few hours.
Please suggest me the way to transmit data out of transaction before it ends up.
UPD: I’ve found the way to transmit progress: I can increase sequences from within my procedure, and read them from other connection. http://blog.endpoint.com/2010/04/viewing-postgres-function-progress-from.html
You can use the dblink extension to connect back to the database and execute statements on a different connection. This is also commonly used for logging errors before a transaction rolls back, for example.
Quick demonstration:
produces:
so you can see that these are two separate sessions. dblink provides functionality to open a persistent connection etc. that this simple usage skips over. Provided that you already have a schema to put the progress information into, then you can simply call dblink() to populate/update it via the second connection, while your first connection continues to execute its long transaction.