How does the Convex Dashboard calculate the total count of documents for a given table? Does it use the aggregate/sum component or is it doing a query or is the count stored somewhere? I want to get the sum of counts across for a specific table across multiple production environments ideally without having to add new components or change the convex code or run scans
#Document Counter in Convex Dashboard?
8 messages · Page 1 of 1 (latest)
Hi @split current. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The knowledge sources indicate that Convex does maintain an internal per‑table document count that the Dashboard uses, but this is not part of the public, supported API.
In the “Why doesn't Convex have SELECT or COUNT?” article, the author notes:
“there is actually a cheeky global count for tables in Convex, that's how the Convex dashboard is able to show this number… It’s not documented and not officially visible through the types but it’s there. Buuuut I wouldn't use it in production if I were you, unless you wanted your app to break at one point without warning!” [Why no SELECT/COUNT]
So, based on the docs:
- The Dashboard’s table row count is coming from an internal global count, not from the Aggregate or Sharded Counter components, and not from a user‑level query. [Why no SELECT/COUNT]
- That internal count is intentionally undocumented and not meant for app code; relying on it from your own functions is explicitly discouraged. [Why no SELECT/COUNT]
Regarding your goal:
“get the sum of counts for a specific table across multiple production environments … without adding components / changing Convex code / running scans”
The knowledge sources do not describe any supported way to read that internal global count from user code or from outside Convex, nor any built‑in cross‑environment aggregation of those counts. They only suggest:
- Manually maintaining counts in your own schema or via components like Sharded Counter or Aggregate. [Sharded Counter; Aggregate]
- Avoiding the undocumented global count for production use. [Why no SELECT/COUNT]
So, with the information available:
- The Dashboard uses an internal, undocumented per‑table count.
- There is no documented, supported way to reuse that mechanism from your own code or to sum it across environments without adding your own counting logic or components.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@split current Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@charred harness I want to get those counts for a onetime estimate, not for my app to rely on. how do i do that
Let me check the knowledge base for you again. One moment! :books:
The knowledge sources don’t describe any supported way to read the internal per‑table counts that the Dashboard uses. The article only mentions that this “cheeky global count” exists and explicitly warns against using it, without giving an API, function name, or pattern you could call from your own code. [Why no SELECT/COUNT]
Because of that, I can’t point you to a documented trick or endpoint to grab those counts even for a one‑time estimate. From what’s documented, your only supported options are:
- Add your own counting mechanism (e.g. Sharded Counter or Aggregate) and backfill once, then read the count. [Sharded Counter; Aggregate]
- Or export a snapshot and count rows offline (e.g. with
npx convex exportand a local tool likejq/DuckDB). [Backup export; Observability snapshot]