The Analytics Stack Audit a Small Supabase Engineering Team Runs Before Touching Infrastructure
Establish data access, query patterns, and security gaps before your infrastructure changes.

Analytics for Supabase teams should begin with an audit. The audit maps data access, query load, and metric definitions so the team can protect both its production database and the decisions made from it. A small engineering team can run this safety check with available Postgres instrumentation, a structured review, and a clear owner for the findings.
Why the analytics audit comes before any infrastructure change
Supabase is Postgres with a developer experience layer, so its data model remains legible across different team compositions. That legibility gives engineers a useful starting point, but an infrastructure change can disrupt the baseline they understand. A migration, re-provisioning, or scaling exercise can amplify an unindexed foreign key, a misconfigured access policy, or a query already consuming a dangerously high share of CPU. After the change, it is harder to tell which weaknesses were already there.
The audit therefore asks who can reach which data, by what path, and what the system records about that access. It connects those answers to the workload running against the database and the numbers derived from it. This is broader than checking whether reports load. Without that record of how things worked before the change, the team may find a performance regression with nothing useful to compare it with, or widen access without knowing which policies and logs cover it. The infrastructure decision then rests on assumptions the team has not tested.
What the platform logs and default dashboards actually show — and where they stop
Provider dashboards supply system-level metrics such as CPU, disk usage, and replication lag without additional instrumentation. These are useful signals about the database as a whole. They are not a complete safety baseline. The team needs query-level and connection-level data behind those summaries to explain the load or find out what happened during an incident.
A dashboard with no red flags cannot establish that individual queries are efficient, connections are accounted for, or RLS policies are correct. Platform logs also leave gaps, especially in what they record about database operations through automated or privileged access paths.
Teams asking how to get analytics and dashboards for a Supabase project need to understand these limits before they choose tools. Operational dashboards describe system health, while analytical dashboards present business metrics. Neither replaces the query, connection, and access checks needed to establish that the underlying database is safe to change.
The query and connection picture: what pg_stat_statements reveals that dashboards miss
The minimum viable query instrumentation uses pg_stat_statements and auto_explain, both available without additional infrastructure. The former is enabled by default on most managed Postgres and records query mean time, total time, and call count. Total time identifies where database work accumulates. A weekly review should examine the top queries by total time, compare mean execution time this hour with the same hour last week, and inspect call-count anomalies. A sudden increase in calls often points to a missing cache or a polling loop.
While those statistics identify expensive query patterns, auto_explain supplies execution plans for queries slower than a configured threshold. Setting that threshold to the service-level objective means a later regression can have its plan already in the log. The connection baseline should also record how close active connections are to max_connections, which connections are idle-in-transaction, and where lock waits occur, using pg_locks joined to pg_stat_activity. An idle transaction lasting more than a few minutes is a bug.
Before infrastructure work starts, alerts should flag when connections near their limit, average query time goes above the acceptable baseline, or error rates rise above a small fraction of requests. The system-level checks should also flag high disk usage and CPU that stays high.
Schema anti-patterns that compound quietly and become dangerous after a change
Runtime observations show what the current workload costs, but they do not exhaust the risks in the schema. Weaknesses in the schema can go unnoticed until traffic rises, a migration runs, or a feature changes the workload. Low load can conceal a costly design. The schema review therefore belongs before infrastructure work, rather than after a regression makes the weakness visible.
An unindexed RLS policy column provides a concrete example. A policy such as user_id = auth.uid() can require a full sequential scan on every request when user_id is not indexed. When there are few rows, that cost can be easy to miss. At large scale, the same pattern can time out, even though the policy itself has not changed.
The audit should check whether foreign keys and RLS columns have indexes, whether tables that grow with user count are ready for partitioning, and whether public-facing tables have policies. Automated checks can also flag types such as varchar(n) and timestamp without time zone for review against Postgres type best practices. These findings require assessment before deciding which flagged columns to rewrite. Their purpose is to expose structural risks before an infrastructure change magnifies them.
RLS coverage as the audit's most consequential check
Row-Level Security shifts the audit from database cost to data exposure. For tables that can be reached through the PostgREST API, missing RLS protection leaves an access-control gap. The schema review must therefore distinguish two related questions, namely whether a policy correctly restricts access and whether its supporting columns are indexed. A missing index threatens performance, while missing or incorrect protection threatens confidentiality.
For every API-accessible table, the audit should establish whether a policy exists, whether the policy column is indexed, and whether the policy has been tested against real access patterns. Those tests include invites, role changes, and org switching.
Supabase manages server infrastructure, but the team remains responsible for schema design, RLS policies, backup configuration, and API key management. That responsibility boundary is where assumptions about platform protection can leave gaps. RLS debugger tooling makes policy verification part of the audit workflow and reduces reliance on manual testing. The resulting artifact should be a table-by-table coverage map, with index status and policy-test findings.
Audit trails: what the system records about who did what, and where the gaps are
Access controls describe what a connection may do, while audit trails record what it actually did. Covering all Supabase access paths requires combining the PostgreSQL extension pgaudit with platform logs. Neither source supplies the whole picture alone. Operations performed by automated agents or shared accounts under service_role may leave no trace in default platform logs, preventing the team from answering what that connection queried.
The audit should examine every automated database connection, including backend jobs, scripts, and agents. For each, it should establish the role in use, whether that role bypasses RLS, and whether its queries appear in the audit log. Without connecting the permission map to recorded activity, the team cannot verify its assumptions about how privileged access is used.
Recording and enforcement are separate controls. A live enforcement layer such as hoop.dev can check statements before execution, stop unconstrained deletes and table drops, and return a Postgres error to the caller. That does not remove the need for an audit trail. Recording activity becomes more complex when AI agents join the connection pool, because their access introduces additional workload and analytical risks.
How AI agents change the access-path risk and what the audit must add
AI agents inherit the RLS and audit-trail risks of any other service_role connection. They also introduce unpredictable query patterns that can exhaust the connection pool and produce metric hallucinations when they construct SQL against raw schemas. A valid SQL result can still be analytically wrong. Exploratory queries can leave connections open while answering a business question without the governed definition that gives the result its meaning.
An agent using service_role can still bypass RLS and exhaust connections even if it cannot write. The audit should verify read-only enforcement, role- and attribute-based controls scoped to the requester's permissions, and a log of every agent query. These access checks are familiar, but how often agents query the database makes them more urgent.
For analytics, the recommended pattern is an MCP server querying a governed copy of the data, rather than allowing agents to reach production directly. This separates analytical traffic from the operational database and gives agents the team's metric definitions. The July 28, 2026 revision of the MCP protocol's specification made the protocol layer stateless, so requests can reach any server instance behind a plain load balancer. That change makes horizontally scaled governed layers more practical for concurrent agent traffic.
The U.S. National Security Agency's Artificial Intelligence Security Center warned in a May 2026 Cybersecurity Information Sheet that MCP's rapid proliferation had outpaced development of its security model. Operational simplicity does not establish safe access. The governed layer is a trust boundary.
Whether the numbers the team acts on can actually be trusted
Even with full access controls and query logs, the team cannot be sure that a dashboard's numbers mean what it thinks they mean. Sales, finance, and product may each maintain a different definition of ARR or active users. The database can run every query correctly and still produce reports that disagree. This metric drift moves the failure from infrastructure into decision-making.
The audit should establish whether core metrics have one agreed definition, one source, and one calculation recorded in a data dictionary. It should also trace each dashboard metric to its appropriate source, including revenue from the billing system, usage from the analytics layer, and cash from the bank. Untraceable metrics become explicit findings. The audit exposes whether this governance exists rather than treating a new dashboard as its substitute.
Scope is part of that check. Early-stage teams should examine whether the later-stage company metrics they track predict their own growth. The North Star Metric principle gives the review a hierarchy, with one number representing the value the product delivers and other metrics feeding or explaining its movement. The audit should test whether that hierarchy exists and whether its calculations are consistent.
Running the audit without a dedicated data team
This audit requires available Postgres instrumentation, a structured checklist, and an owner for the findings. Start with pg_stat_statements and auto_explain, supported by provider dashboards for system baselines and an alert for each key threshold. The remaining work is a bounded review. It covers schema indexes and RLS gaps, automated connection logs, and definitions for the team's core KPIs.
An external audit partner is most useful where the team needs help assessing its side of the platform responsibility boundary. Server management does not settle questions about schema design, policies, backups, or API keys. A partner can surface gaps in those areas before an infrastructure change amplifies them. That is a way to obtain a focused assessment without hiring a dedicated data team.
Deferring the work until after scaling reverses the useful order. Before a change, the team still has a stable reference against which to record query costs, connection behavior, and access patterns. Afterward, unresolved gaps compete with the effects of the change itself. It costs less to make sense of the audit while the baseline is still intact.
What a completed audit produces and what happens next
A completed audit produces four decision artifacts. The query and connection baseline lets the team compare performance before and after the change, while the RLS coverage map shows what protection and indexes each public-facing table has. The audit-trail inventory lists the automated and agent connections and the roles they use. The metric-definition review distinguishes numbers the team can trust from those it cannot.
Those findings determine the order of work. If CPU stays above the danger threshold, the team needs to look at the top queries before migration. RLS gaps should close before traffic scales, and missing agent audit trails should be added before agent workflows expand. Metrics that cannot be traced to their source call for a repaired data dictionary before more dashboards are added.
The baseline also needs renewal as the project changes. Reviewing top queries each quarter, testing policies from time to time as access patterns change, and checking the definition of each new KPI keep the audit useful beyond the infrastructure decision at hand.


