## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.
YES
## What kind of change does this PR introduce?
This introduces Query Insights. It's the first edition of possible
future updates. This takes our old prototype and builds upon it for a
more action driven insights view.
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Ali Waseem <waseema393@gmail.com>
Add a Query Performance page implementation powered by
[supamonitor](https://github.com/supabase/supamonitor).
[Context](https://linear.app/supabase/project/build-extension-for-supabase-query-insights-df4fb145352c/overview)
This looks largely the same as the pg_stat_monitor implementation:
<img width="2556" height="960" alt="Screenshot 2026-02-12 at 7 35 47 PM"
src="https://github.com/user-attachments/assets/bf37466e-f7af-41f2-b4f2-cf8eb6a8c76f"
/>
Only available on projects on custom AMI - existing users are unaffected
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Supamonitor-based query performance view: charts, aggregated metrics,
date-range controls, and export/download.
* Added "Application" column for per-application tracking.
* Interactive Supamonitor grid: sorting, filtering, keyboard navigation,
selection, retry/error handling.
* Automatic per-project Supamonitor detection with toggleable UI
integration.
* **Bug Fixes**
* Chart latency calculation prefers histogram data for more accurate
p95.
* **Documentation**
* Minor blog formatting fix.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: kemal <hello@kemal.earth>
Co-authored-by: Ali Waseem <waseema393@gmail.com>
* feat: setup chart area and tabs
This sets up the area where we can expect the insights chart as well as the tabs mechanism.
* feat: parse pg_stat_monitor logs as json
* feat: create query perf chart utils and move transfrom function
Created a utils file for our QueryPerformanceChart component. This moves the logs to JSON transform function there.
* feat: add timerange to chart
* feat: add date selector to query perf overview
This adds the selector to the top right of the page allowing the user to switch between last hour, 3 hours and 24 hours
* feat: modify chart component to accomodate hiding bits
* feat: add metrics to each tab
* chore: update to 60 min by default and some css
* feat: centralise data parsing for logs
* feat: clean up filters bar
This rewires the export to give you the aggregate pg_stat_monitor data. Also removes unused buttons and filters.
* feat: percentiles for query latency chart
* feat: filter out non evenets from pg_stat_monitor logs
* feat: utils for cache misses and hits
* feat: add selected query to chart on click
* feat: add click through to query panel
* chore: tidy up files
* chore: distinction between selected and open panel
* feat: move query performance fully into reports area
* fix: preserve query params on reports link
* fix: remove right icon syntax in report menu
* chore: remove cache misses from cache chart
* refactor: backwards compatibility for statements if right db version isnt available
* chore: delete randomly generated empty file
* chore: tidy up unused imports and vars
* chore: remove console logs
* chore: remove isMounted from query perf
* fix: cmd k query perf path
* feat: simplify query latency only p50 and p95
This seems to give us a more accurate reading as we can calculate these two
* fix: cache hit rate not showing inside query details
* chore: chart bg colour adjust
So it contrasts a little better on light mode.
* feat: show selected query on other verticals
* feat: bring back symlink in advisors
* feat: add pgbouncer description to query perf
This was missing for queries that still use pgbouncer as a role.
* chore: update description string for pgbouncer
* chore: unbluntify copy string
* feat: move query details to sheet
This moves the click through on Query Performance to a sheet as opposed to a resizable area. This gives us more space to play with and sets us up for the Query details revamp.
* fix: tabs font size
* style: expand size of sheet
* feat: hasOverlay prop for sheets
* feat: add optional overlay for sheets
* fix: closing only when clicking outside of rows
* style: width of panel on different viewports
* fix: horizontal scroll for table
* fix: query queries label check in metrics
* feat: change calls label to count
This changes the column title for calls to count for clarity
* feat: add cache hit rate col and number formatting
Adds a cache hit rate column for each query as well as tidies up some number formatting.
* feat: add styling for 0 numbers
This makes anything marked as 0 feint in the table for easier parsing.
* chore: remove debug console log
* fix: silly next-env again
* nit: remove avg rows col
* nit: add toFixed to cache hit rate
* feat: add tooltip for role column
* feat: remove tabs and unify columns
This removes the tabs from Query Performance with unified columns in the table.
* chore: remove unused imports
* chore: small adjustment to min max and mean time col size
* feat: original experiment with metric cards
* fix: height of table container on load
* feat: add percentage background for time consumed col
Adds a percentage based background colour for time consumed column and reshuffles some columns.
* feat: working metrics above rows
* feat: simplify stats + go back full width
* style: bring up percentage bar opacity
* chore: remove reportType again
* feat: add metric queries to reset function
* fix: type error for passing query metrics
* fix: query queries plural thing
* chore: remove next-env weirdness
* feat: remove tabs and unify columns
This removes the tabs from Query Performance with unified columns in the table.
* chore: remove unused imports
* chore: small adjustment to min max and mean time col size
* chore: remove unused prop
* feat: tidy up query perf column headers
* feat: update col widths and which ones are sortable
This gives a reasonable column width to all cols as well as adds an option for us to filter out which columns we dont want to make the table sortable by.
* feat: column order and word wrapping for query
* feat: column data text align for numbers
* fix: pointer event was preventing index advisor icon popover
* feat: use code block instead of editor
Swapped Editor out for Code block as its less expensive and modified it to add pgsql syntax highlighting
* fix: small truncation issue
* chore: remove unused sort function
* fix: sort menu closing on first click
Sort menu of a column no longer disappears on first click
* feat: move sorting and ordering over to nuqs
This removes the usage of Next Router params and uses Nuqs instead for managing the QP table sorting and ordering.
* feat: add clear sorting button to filter bar
* chore: remove unused files
* fix: add highlighting for selected sort
* Nit update sort
* nit: smol styling update for direction
* feat: inian feedback on time based numbers
* fix: return number instead of string for total time
We were returning a string for total time percentage which meant the sorting was a little bit off
* Shift roles to nuqs
* chore: clean up
* fix: smaller viewport filter bar
---------
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
* Add CodeBlock for SQL query display to add syntax highlight
* use monaco editor for better highlighting
* create `SqlMonacoBlock` component for SQL in detail panel
* add mean_time to most_time_comsuming queries
* make outline transparent
* Add keyboard navigation for query performance grid
* Stop default RDG behavior on arrow key navigation
* Update column minWidth values to remove horizontal scrollbar
* Load SqlMonacoBlock and Editor client-side only
- following a pattern in `SQLEditor.tsx`
* init
* hovercard
* adds button to install index advisor
* hover card now now insert indexes
* update
* moved hook
* align alert dialog to design syste,
* Update index-advisor.utils.ts
* shows all index statements now
* Update query-performance.tsx
* Some refactors
* Clean up
* Fix
* One last nit refactor
---------
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>