Avoiding timeouts in long running queries

Last edited: 1/17/2025

Certain queries, like indexing a table or changing a column's data type, are inherently time-consuming. The Dashboard's SQL Editor has a 1-minute timeout limit.

To execute long-running queries, follow the below steps.

Install an external SQL client

The guide focuses on psql but you can use any Postgres client.

Some other options include:

You can install PSQL in macOS and Windows by following these links and instructions. For Linux (Debian) you can run the following:


_10
sudo apt-get update
_10
sudo apt-get install postgresql-client

Once installed, you can find your PSQL string in the Database Settings. Please make sure if you are using the pooler connection that it is in session mode (port 5432).

Increase the query timeout

Then you can increase the query timeout solely for your session:

Long timeout


_10
set statement_timeout = '120min';

Disable timeout


_10
set statement_timeout = '0';

If your task is particularly long, you can may want to consider boosting your computing power temporarily. Compute size on Supabase is charged by the hour, so you can increase it for an hour or two, complete your task faster, then scale it back afterward.

If you want to temporarily upgrade, you can find the add-ons for your project in your Dashboard's Add-Ons Settings.