My php/postgree app has follow problem:

When some users run the page proccess.php , it run a complex query in postgree.
In some cases , php return timeout, but postgree process continue at server.

How I can stop the query via SQL in php code?

In my code, I'll do: (simple syntex)

if php_time_out {


I prefer don't change a global limit_time in Postgre database.