pgsql: Timeout queries only when needed.