Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add replication status as a report within the dashboard's SQL snippets

Paul Cioanca55b2a3f98f88
diff --git a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
index bfe5fec01a1..26ce0c751b8 100644
--- a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
+++ b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
@@ -1158,6 +1158,23 @@ as $$
$$;
`.trim(),
},
+ {
+ id: 21,
+ type: 'template',
+ title: 'Replication status report',
+ description: 'See the status of your replication slots and replication lag.',
+ sql: `-- Replication status report
+
+SELECT
+ s.slot_name,
+ s.active,
+ COALESCE(r.state, 'N/A') as state,
+ COALESCE(r.client_addr, null) as replication_client_address,
+ GREATEST(0, ROUND((redo_lsn-restart_lsn)/1024/1024/1024, 2)) as replication_lag_gb
+FROM pg_control_checkpoint(), pg_replication_slots s
+LEFT JOIN pg_stat_replication r ON (r.pid = s.active_pid);
+`,
+ },
]
export const SQL_SNIPPET_SCHEMA_VERSION = '1.0'