workflowproducts / envelope

Publish web apps based on your PostgreSQL database fast!
https://workflowproducts.com/envelope.html
Apache License 2.0
53 stars 2 forks source link

Detect long-running Queries #131

Closed nunziotocci closed 5 years ago

nunziotocci commented 6 years ago

Envelope should keep track of what queries it's running and when they started so that if it takes a certain amount of time it issues a log.

This would be configurable by the config parameter log_queries_over=<seconds>. If set to zero, don't issue logs.

Also, these logs should be issued no matter what the log_level is.

It would be interesting if you could attach a custom action to this handler, but that would need to be discussed.

justintocci commented 6 years ago

it would be cool to call a database function when this happens, because then it would be a piece of cake to notify the sysadmin of the long running query via text or email.

nunziotocci commented 6 years ago

Ok, I'll add a log_queries_over_action_name=<pg_function> parameter and Envelope will pass the PID of the process to the function.