For debugging slow queries, you can get the Postgres EXPLAIN
execution plan of a query using the explain()
method. This works on any query, even for rpc()
or writes.
Explain is not enabled by default as it can reveal sensitive information about your database. It's best to only enable this for testing environments but if you wish to enable it for production you can provide additional protection by using a pre-request
function.
Follow the Performance Debugging Guide to enable the functionality on your project.
If `true`, include information on WAL record generation.
If `true`, the query identifier will be returned and `data` will include the output columns of the query.
If `true`, include information on configuration parameters that affect query planning.
The format of the output, can be `"text"` (default) or `"json"`.
The format of the output, can be `"text"` (default) or `"json"`.
If `true`, include information on buffer usage.
If `true`, the query will be executed and the actual run time will be returned.
response = supabase.table("countries").select("*").explain().execute()
response = (
supabase.table("countries")
.select("*")
.explain(analyze=True, verbose=True)
.execute()
)