JavaScript: Using explain

Return data as the EXPLAIN plan for the query.

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.

Parameters

Examples

Get the execution plan

const \{ data, error \} = await supabase
  .from('countries')
  .select()
  .explain()

Get the execution plan with analyze and verbose

const \{ data, error \} = await supabase
  .from('countries')
  .select()
  .explain(\{analyze:true,verbose:true\})