Skip to content

Conversation

NickLittman
Copy link
Contributor

@NickLittman NickLittman commented Oct 20, 2025

What kind of change does this PR introduce?

New feature - Adds inspect db traffic-profile command

What is the current behavior?

No built-in command to analyze table read/write I/O patterns.

What is the new behavior?

Adds supabase inspect db traffic-profile command that analyzes PostgreSQL statistics (pg_stat_user_tables and pg_statio_user_tables) to categorize tables by workload:

  • Read-Heavy - Read operations are more than 5x write operations (e.g., 1:10, 1:50)
  • Write-Heavy - Write operations are more than 20% of read operations (e.g., 1:2, 1:4, 2:1, 10:1)
  • Balanced - Mixed workload where writes are between 20% and 500% of reads
  • Read-Only - Only read operations detected
  • Write-Only - Only write operations detected

Example output:

SCHEMA │ TABLE        │ BLOCKS READ │ WRITE TUPLES │ BLOCKS WRITE │ ACTIVITY RATIO
───────┼──────────────┼─────────────┼──────────────┼──────────────┼────────────────────
public │ user_events  │     450,234 │     9,004,680│       23,450 │ 20:1 (Write-Heavy)
public │ users        │      89,203 │        12,451│        1,203 │ 7.2:1 (Read-Heavy)

Additional context

  • Query adapted from Crunchy Data's blog post on analyzing Postgres read/write patterns
  • Follows existing inspect command patterns
  • Includes unit tests and documentation
  • Tests passing: ✅

@NickLittman NickLittman requested a review from a team as a code owner October 20, 2025 20:51
@coveralls
Copy link

coveralls commented Oct 20, 2025

Pull Request Test Coverage Report for Build 18718316541

Details

  • 14 of 24 (58.33%) changed or added relevant lines in 2 files are covered.
  • 7 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 54.587%

Changes Missing Coverage Covered Lines Changed/Added Lines %
cmd/inspect.go 0 4 0.0%
internal/inspect/traffic_profile/traffic_profile.go 14 20 70.0%
Files with Coverage Reduction New Missed Lines %
internal/storage/rm/rm.go 2 80.61%
internal/gen/keys/keys.go 5 12.9%
Totals Coverage Status
Change from base Build 18712223732: -0.02%
Covered Lines: 6403
Relevant Lines: 11730

💛 - Coveralls

Copy link
Contributor

@sweatybridge sweatybridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Should we include this in the report command as well?

@NickLittman NickLittman force-pushed the feat/traffic-profile-cmd branch from f241861 to 7159aa5 Compare October 22, 2025 13:46
@NickLittman
Copy link
Contributor Author

NickLittman commented Oct 22, 2025

@sweatybridge good call, it seems a trailing ; was blocking the report from running the traffic-profile command. Fixed this now.

@NickLittman NickLittman merged commit 1240cbc into develop Oct 22, 2025
10 of 11 checks passed
@NickLittman NickLittman deleted the feat/traffic-profile-cmd branch October 22, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants