By default, Supabase limits the maximum statement execution time to 3 seconds for users accessing the API using the anon key, and 8 seconds for authenticated users. Additionally, all users are subject to a global limit of 2 minutes. This serves as a backstop against resource exhaustion due to either poorly written queries, or abusive usage.
The timeout values were picked as a reasonable default for the majority of use-cases, but can be modified using the
alter role statement:
You can also update the statement timeout for a session:
All Supabase projects come with the
pg_stat_statements extension installed, which tracks planning and execution statistics for all statements executed against it. These statistics can be used in order to diagnose the performance of your project.
This data can further be used in conjunction with the
explain functionality of Postgres to optimize your usage.