Skip to content

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

Updated SQLEditor.constants.ts - Added query to see cache & index hit rate

Kevin Brollyac0bec65e3b9
diff --git a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
index 40a80e8e7b7..b9c908eeae3 100644
--- a/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
+++ b/studio/components/interfaces/SQLEditor/SQLEditor.constants.ts
@@ -977,6 +977,7 @@ GRANT ALL ON TABLE next_auth.verification_tokens TO service_role;
sql: `-- Most frequently called queries
-- A limit of 100 has been added below
+
select
auth.rolname,
statements.query,
@@ -1052,5 +1053,22 @@ select
max_time desc
limit
100;`,
+ },
+ {
+ id: 19,
+ type: 'template',
+ title: 'Hit rate',
+ description: 'See your cache and index hit rate.',
+ sql: `-- Cache and index hit rate
+
+select
+ 'index hit rate' as name,
+ (sum(idx_blks_hit)) / nullif(sum(idx_blks_hit + idx_blks_read),0) as ratio
+ from pg_statio_user_indexes
+ union all
+ select
+ 'table hit rate' as name,
+ sum(heap_blks_hit) / nullif(sum(heap_blks_hit) + sum(heap_blks_read),0) as ratio
+ from pg_statio_user_tables;`,
}
]