Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thepf_aggregate_resource_usage() function rolls up realtime usage into daily/monthly periods. It should be scheduled to run periodically via pg_cron.
Function
- Iterates all active quotas with
reset_period='daily'or'monthly' - Sums realtime usage rows for the current period
- Upserts aggregated rows into
pf_resource_usagewithaggregation_period = 'daily'or'monthly'
Scheduling via pg_cron
Prerequisites
Enablepg_cron and pg_net extensions in the Supabase Dashboard → Database → Extensions.
Recommended Schedule
Via Supabase Dashboard
- Go to SQL Editor → New Query
- Paste the
cron.schedule(...)SQL above - Run the query
Verification
Notes
- The aggregation function is idempotent (uses UPSERT)
- No edge function needed — runs directly in Postgres
- Realtime rows older than 7 days can be safely pruned
- Monitor via
pf_resource_usagerow counts per aggregation_period