# Postgres error 57014: canceling statement due to statement timeout

> The statement ran longer than statement_timeout (or was cancelled by the user) and was stopped.

Source: https://scribase.com/postgres-errors/57014

SQLSTATE class: Operator Intervention. Over PostgREST/supabase-js this maps to HTTP 500.

## Causes

- A slow query: missing index, sequential scan of a big table, or a plan gone wrong.
- A short timeout on the API role, which is common on hosted backends to protect the database.
- Waiting on a lock held by another long transaction.

## Fixes

- EXPLAIN (ANALYZE, BUFFERS) the query and add the index it needs; pg_stat_statements shows which queries are slow overall.
- Paginate large reads with keyset pagination instead of OFFSET.
- For known long jobs, raise the timeout only where needed: set local statement_timeout = '60s'; inside the transaction.