statement_timeout

You can control the maximum amount of time that any single query can take to execute before it is cancelled as a failure. Send the sql command like this:

set statement_timeout=10000

The value is an integer, representing milliseconds of execution. This example would make all queries on the current connection be limited to 10 seconds max.