Describe your process for optimizing a slow-running SQL query on Turo data.
Use PostgreSQL's pg_stat_statements view to identify the most expensive statements. The result should focus on statements with positive, non-NULL total execution time and support prioritizing optimization work.
pg_stat_statements.query, calls, total_exec_time, mean_exec_time, rows, shared_blks_hit, and shared_blks_read.total_exec_time descending, then query ascending. Ignore rows where total_exec_time is NULL.| Column | Type | Description |
|---|---|---|
| query | VARCHAR(500) | Normalized SQL statement text |
| calls | BIGINT | Number of times the statement was executed |
| total_exec_time | NUMERIC(20,3) | Total execution time in milliseconds |
| mean_exec_time | NUMERIC(20,3) | Mean execution time per call in milliseconds |
| rows | BIGINT | Total rows returned or affected |
| shared_blks_hit | BIGINT | Shared buffer cache hits |
| shared_blks_read | BIGINT | Shared blocks read from storage |