Skip to main content

Dashboard Configuration

This extension requires activation via the PlanetScale Dashboard before it can be used. It must be enabled through shared libraries and requires a database restart. To enable pg_stat_statements:
1

From the PlanetScale organization dashboard, select the desired database
2

Navigate to the Cluster configuration page from the menu on the left
3

Choose the branch whose extensions you’d like to configure in the “Branch” dropdown
4

Select the Extensions tab
5

Enable pg_stat_statements and configure its parameters
6

Click Queue extension changes to apply the configuration
7

Once you’re ready to apply the changes, click “Apply changes

Parameters

pg_stat_statements.max

  • Type: Integer
  • Default: 5000
  • Description: Maximum number of statements tracked by the extension.

pg_stat_statements.track

  • Type: Select
  • Options: top, all
  • Default: top
  • Description: Which statements to track. ‘top’ tracks top-level statements only, ‘all’ tracks all statements including nested ones.

pg_stat_statements.track_utility

  • Type: Boolean
  • Default: true
  • Description: Whether to track utility statements (such as PREPARE, EXPLAIN, etc.).

pg_stat_statements.track_planning

  • Type: Boolean
  • Default: false
  • Description: Whether to track planning statistics for statements.

pg_stat_statements.save

  • Type: Boolean
  • Default: true
  • Description: Whether to save statement statistics across server restarts.

Usage

After enabling the extension through the dashboard, you can install it in your database:
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
Then you can query the statistics view:
-- View the most time-consuming queries
SELECT 
    query,
    calls,
    total_exec_time,
    mean_exec_time,
    rows
FROM pg_stat_statements 
ORDER BY total_exec_time DESC 
LIMIT 10;

External Documentation

For more detailed information about pg_stat_statements usage and the available statistics, see the official PostgreSQL documentation.