PostgeSQL ERROR: canceling statement due to statement timeout

ERROR: canceling statement due to statement timeout

The above error happens due to the PostgreSQL database timeout and we can modify this value in three levels.

This article explains all the three methods of modifying the PostgreSQL database timeout value.

Statement timeout can be configured in the database level.

>ALTER DATABASE DB SET statement_timeout = 'Ts';

Where DB and T need to be replaced with the database name and time in seconds respectively.

Statement timeout can be configured in the user level.

>ALTER ROLE USER SET statement_timeout = 'Ts';

Where USER and T need to be replaced with the user name and time in seconds respectively.

Statement timeout can be configured for the single session.

>SET statement_timeout = 'Ts';

Where T need to be replaced with time in seconds.

We can make the statement timeout value at session level for permanently by updating the following line in PostgreSQL configuration file.

SET statement_timeout = 'Ts';

Where T need to be replaced with time in seconds.

Please note that the time can be specified in minutes also for all the above cases.

That's all…

Leave a Reply