From 33fdf6a7cee6d61703a137b6c215e660474c900f Mon Sep 17 00:00:00 2001 From: Yang Cen Date: Thu, 3 Dec 2026 03:16:29 +0800 Subject: [PATCH] docs: document visible row counts for RTE tables (#5362) ## Summary Document how to count visible rows in an Enterprise Realtime Engine table. Use `COUNT(*)` when Flight SQL is reachable, or sum Arrow batch sizes from an unbounded, one-column REST scan. Explain the cost of the REST scan and the scope of the explicit base-table count. ## Validation Exercised both routes through published Python clients on isolated Linux. The large fixture returned 100,000 visible rows, then 99,999 after an overwrite and a base-key delete, then 99,998 after a fresh-key delete. An independent key/value oracle matched each stage. The REST base-only count stayed at 80,000 and the default REST count returned HTTP 400. --- docs/web/search/realtime-read.mdx | 37 ++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/web/search/realtime-read.mdx b/docs/web/search/realtime-read.mdx index d87d98c81..e77b6d482 100644 --- a/docs/web/search/realtime-read.mdx +++ b/docs/web/search/realtime-read.mdx @@ -49,6 +49,40 @@ for a full scan of the memtable only when it can't honor the query through a graph -- a prefilter, a primary-key override, a distance lower bound, or before the memtable has any index yet on a cold start. +## Count visible rows in Enterprise {#count-visible-rows} + +On an RTE-enabled Enterprise table, `count_rows()` returns HTTP 400. +The following queries count the visible rows after merging the base table and +the fresh tier by primary key, including the effects of fresh deletes. + +### With Flight SQL + +If your client can reach the deployment's Flight SQL endpoint, use +[`execute_query()`](/basics/sql#sql-from-python) with `COUNT(*)`. In this +example, `db` connects to the same database as `frames` and sets +`sql_host_override` to that endpoint. + +```python +reader = db.execute_query("SELECT COUNT(*) AS visible_rows FROM frames") +visible_rows = reader.read_all()["visible_rows"][0].as_py() +``` + +### With REST + +If your client connects over REST only, scan one column without a limit +and sum the Arrow batch sizes. + +```python +batches = frames.search().select(["frame_id"]).use_rte(True).to_batches() +visible_rows = sum(batch.num_rows for batch in batches) +``` + +This scans the table and transfers the selected column for every visible row. +Use the primary key or another small column to limit the data transferred. + +The REST `count_rows` endpoint accepts `use_rte=false` for a base-table count. +That count excludes RTE changes that have yet to be compacted into the base table. + ## Embedded: one process, one dataset {#embedded} LanceDB Embedded runs this same LSM scanner directly against the local Lance @@ -72,7 +106,8 @@ returning a result that omits un-compacted rows. Support for all table operations on RTE tables is coming soon. Time travel,{/* Draft until branching reaches early access: restore " branching," */} `count_rows`, row IDs (`with_row_id`), and `TABLESAMPLE` are not yet -available. +available. In Enterprise, you can [count visible rows](#count-visible-rows) +using Flight SQL or a REST scan. ## Next steps {#next-steps}