Skip to content

turbostats: a database counts its tables and its partitions - #452

Merged
turbolytics merged 1 commit into
mainfrom
turbostats/table-count
Oct 10, 2026
Merged

turbolytics merged 1 commit into
mainfrom
turbostats/table-count

Conversation

@turbolytics

Copy link
Copy Markdown
Owner

DatabaseResources gains two optional fields:

  • table_count: the tables in the database's own schemas, partitions included. System catalogs are not counted.
  • partition_count: how many of those tables are partitions.

Why

A table partitioned by day adds a partition each day until retention drops one. If retention stops, the partition count climbs before the disk fills, and no report showed it. Control's own database holds 172 tables, 148 of them partitions under 10 parents.

Tests

  • TestDatabaseResources_TableAndPartitionCountsRoundTrip fails to build without the fields. It also checks that a kind that cannot count its tables leaves both fields out.
  • The widest database bundle grows 54 bytes, to 84,091, under the 128 KiB a receiver allows.
  • make schema regenerated bundle.schema.json.
  • Every package that imports turbostats/wire passes vet and test.

After merge

dbhealth pins this commit and sends the counts. Control pins it, stores the counts in database_reports, and shows them on the database page.

A database section said how big the database is, but not how many
tables it holds. A table partitioned by day adds a partition a day until
retention drops one. When retention stops, the partition count climbs
before the disk does, and nothing reported it. Control's own database
holds 172 tables, 148 of them partitions under 10 parents.

DatabaseResources sends table_count, the tables in the database's own
schemas with partitions included, and partition_count, how many of them
are partitions. Both are optional: a kind that cannot count its tables
leaves both out.

One round-trip test, which fails to build without the fields. The widest
database bundle grows 54 bytes, to 84,091, under the 128 KiB a receiver
allows. The schema is regenerated.

If this is wrong, a receiver misreads the two counts. Both fields are
new and optional, so a receiver that does not know them ignores them,
and every existing field is unchanged.
@turbolytics
turbolytics merged commit be0f44f into main Oct 10, 2026
7 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 10, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant