Commit Graph

20 Commits

Author SHA1 Message Date
Vaibhav fdf8732727 fix: Include security_invoker in definition (#44936)
## TL;DR

the table editor definition panel was showing incomplete SQL for views
with `WITH (security_invoker = true)`
ignoring the reloption and making it easy to accidentally strip it when
recreating the view

## prob

When viewing a security invoker view in the Table Editor, the Definition
panel only showed `CREATE VIEW ... AS ...`
 without the `WITH (security_invoker = true)` clause

which caused two issues:

1. the displayed SQL was incomplete and didn't match the actual view
definition
2. users copying the SQL to recreate the view would unintentionally lose
the security_invoker setting


## ex:

| Before | After |
|--------|-------|
| `create view public.exposed_api as`<br>`select id, secret from
public.rls_protected_table;` | `create view public.exposed_api with
(security_invoker = true) as`<br>`select id, secret from
public.rls_protected_table;` |

## ref:
- closes https://github.com/supabase/supabase/issues/44934

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* View definitions now show the full CREATE statement (including
materialized views and WITH (...) options) and preserve security options
like security_invoker when viewed or opened in the SQL editor.

* **Tests**
* Added end-to-end test verifying security option preservation in view
definitions and when opening them in the SQL editor.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-16 07:03:54 -06:00
Charis 3b7052b5a9 cleanup: fix import order and prefixes for studio/data (#44501) 2026-04-03 09:15:57 +02:00
Joshen Lim 241f7bb721 Chore/shift manual queries into pg meta (#43692)
## Context

Related to FE-2557

Part of shifting manually written dashboard queries into
packages/pg-meta where
- pg-meta can be code owners of
- we can write tests for the queries 

This PR just shifts all the `.sql.ts` files that we previously created
into packages/pg-meta

There's still other areas where we need to shift over as well which I'll
address in subsequent PRs

## Notable changes

- `getTableRowsCountSql` -> Opted to shift `formatFilterValue` logic out
before calling this method (ref `table-rows-count-query`)
- `getDeleteOldCronJobRunDetailsByCtidSql` -> Opted to shift
`validatePageNumber` logic out before calling this method (ref
`CronJobsTab.useCleanupActions`)
2026-03-16 16:14:48 +07:00
kemal.earth 7ed8ab83a8 feat(studio): query insights improvements (#43109)
## 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>
2026-03-13 15:09:26 +00:00
Joshen Lim dfd5461ef9 Opt to use connection string of read replica if available to power the table editor (#42856)
## Context

Part of dashboard scalability project

Opting to use the connection string of the project's read replica (if
available) for read queries on the database.

Trialing with the Table Editor as a first pass - changes involved will
opt to use replica connection string for `useTableRowsQuery`,
`useTableRowsCountQuery`, and `useForeignKeyConstraintsQuery`

There's definitely optimizations to be done for deciding which replica
to use - but am starting off with a rather naive logic to prioritize
replicas in the same region as the project.

## Changes involved

- We're no longer passing `connectionString` as a param into the
affected hooks, the `connectionString` is derived from within those
hooks instead
- Change is feature flagged, so things should be status quo if flag is
off (use primary database's connection string)
- Added `useConnectionStringForReadOps` hook which returns the replica's
connection string if (Otherwise defaults to primary database connection
string)
  - Feature flag is on
  - Project has a replica available

## To test

- [ ] Verify that the table editor works as expected for a project that
has read replicas (There shouldn't be any change really)
- [ ] Also just double check that updating cells in the table editor
works as well (There's no change there, we're using the primary DB's
connection string for mutation ops)
- [ ] ^ Same thing for a project that doesn't have read replicas
- [ ] ^ Same thing for local / self-host
2026-03-04 16:34:36 +08:00
Bobbie Soedirgo 105df5291d feat: initial supamonitor changes (#42313)
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>
2026-02-17 15:11:46 +08:00
Ali Waseem e7a4ca9b74 Feature: show index advisor in table editor (#41166)
* added table advisor query

* updated to include table editor performance

* updated JSON B

* added side panel

* updated query indexes to show highlights context

* show index advisor in table editor

* updated invalidation logic

* added color updates

* added query indexes

* updated query performance type

* updated overflow and title

* put behind flag

* remove gap

* added on close

* Update apps/studio/data/database/table-index-advisor-query.ts

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>

* updated styling

---------

Co-authored-by: Charis <26616127+charislam@users.noreply.github.com>
2025-12-10 09:28:45 -07:00
Riccardo Busetti e12984c60f feat(replication): Add dialog to clarify replication requirements and limitations (#39032) 2025-09-29 12:09:26 +02:00
Jonathan Summers-Muir 2815dac7e0 Feat/index suggestions inline (#35107)
* 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>
2025-05-07 19:09:58 +08:00
Jordi Enric d10db0f735 add pgbouncer config and status queries (#33772)
* add queries

* use different keys

* move folder

* rm old files

* Small refactoir

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2025-02-24 11:41:35 +08:00
Joshen Lim 9d6cf3ee51 Add contextual invalidation in SQL Editor (#32675) 2025-01-09 18:06:31 +08:00
Alaister Young 6c592dec99 chore: remove useExecuteSqlQuery() part 2 (#30467)
* foreign-key-constraints

* update entity-types stale time

* schemas query

* deprecate useExecuteSqlQuery

* users count query

* database size query

* indexes query

* keywords query

* migrations query

* table columns

* database functions

* database roles query

* fdws query

* replication lag query

* ongoing queries query

* vault secrets query

* remove unneeded staleTime: 0

* max connections query

* fix entity types key in tests

* Some fixes

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-11-18 05:15:37 +00:00
Alaister Young 0e3bc5804b chore: remove useExecuteSqlQuery (part 1) (#30437)
* chore: remove useExecuteSqlQuery part 1

* fix invalidation

* fixes

* more fixes

* I fixed it, but tested on preview instead of local 🤦🏻

* only refetch table rows and not count on row updates

* removed unneeded invalidations and prefetched new table after create
2024-11-14 15:21:29 +08:00
Joshen Lim 01e81fd400 Chore/assistant tweaks 281024 (#30134)
* Add alpha notice

* Close assistant via cmd i if not focused on monaco

* Add edit with assistant CTA for database functions

* Attach existing function definition when editing a function to prompt

* Leave comments

* Small refactor
2024-10-29 15:10:00 +08:00
Ivan Vasilov 6a29cd2bec feat: Choose which schemas to share with OpenAI (#28594)
* Change the getEntityDefinitions query to accept list of schemas instead of being hardcoded to public schema.

* Add a schema combo box for selecting schemas.

* Use the combobox in the SQL editor to select which schemas should be sent to the AI when asking a question.

* Add configurable schemas to AiPolicyEditor.

* Remove unneeded hook.

* Fix the AI settings modal.

* Add keys to the entity definitions query.

* Fix the AI settings modal which is used by cmdk flow.

* Minor fixes.

* Address feedback

* Some fixes

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-08-15 14:38:19 +08:00
Bobbie Soedirgo f327f2b234 chore: use @supabase/pg-meta for schema mutation (#22619)
* chore: use @supabase/pg-meta for schema mutation

* fix schemas query invalidation

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2024-04-17 11:04:21 +07:00
Joshen Lim b07f8304e0 Feat/integrate index advisor (#22641)
* Update

* Clean up + fix UI

* Add data values to tab

* Add comment

* Format sql query in query details

* Clean uo

* Deprecate old files

* Address comments

* chore: update styles (#22591)

* Midway integrating index advisor

* Add feature flag, reinstate old UI for feature flag

* First iteration of integrating index advisor

* Add more details in index advisor and add feature flag

* Shift explain_query function into pg_temp

* Clean uo

* fix padding

* Update apps/studio/components/interfaces/QueryPerformanceV2/QueryPanel.tsx

Co-authored-by: Alaister Young <alaister@users.noreply.github.com>

* Update UI

* Address some feedback

* Moar addressing feedback

* Update docs url

---------

Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com>
Co-authored-by: Alaister Young <alaister@users.noreply.github.com>
2024-04-11 23:27:34 +08:00
Joshen Lim 0ddd1b4711 Remove duplicated types-query, use enumerated-types-query instead (#21632)
* Remove duplicated types-query, use enumerated-types-query instead

* Fix type
2024-02-29 11:29:57 +08:00
Joshen Lim 18840b5e3b Chore/column editor show types from extensions schema (#19580)
* Show types from extensions schema in table editor

* Shift postgres types to RQ

* Deprecate types store in mobx

* Address feedback

* Update label
2023-12-11 15:11:23 +07:00
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00