feat: add delete rows to table stats (#3783)

add to table stats the number of rows that has
been marked for deletion, but not yet deleted.
note that when a table fragment is removed due to
deletion of all of its rows, these rows are not counted. since the main
use of this feature is to determine when table compaction is needed, the
fact that these rows are not reported should not impact that decision
(deleted table fragments don't need compaction).

Fixes: https://github.com/lancedb/lancedb/issues/3761

Co-authored-by: Claude Opus 5.0 <noreply@anthropic.com>
This commit is contained in:
Yuval Lifshitz
2026-10-07 08:38:31 -07:00
committed by GitHub
co-authored by Claude Opus 5.0
parent becbda70dd
commit 069b2f7d31
10 changed files with 180 additions and 10 deletions
+11
View File
@@ -1362,6 +1362,16 @@ pub struct TableStatistics {
/// The number of rows in the table
pub num_rows: i64,
/// The number of rows marked as deleted across all fragments of the table
///
/// These rows are not included in `numRows`, but still occupy space on disk
/// until the table is compacted, so a large value here indicates that the
/// table should be optimized. Fragments in which every row was deleted are
/// dropped outright, so their rows are not counted here.
///
/// Absent (`undefined`) when the backend does not report deletion counts.
pub num_deleted_rows: Option<i64>,
/// The number of indices in the table
pub num_indices: i64,
@@ -1410,6 +1420,7 @@ impl From<lancedb::table::TableStatistics> for TableStatistics {
Self {
total_bytes: v.total_bytes as i64,
num_rows: v.num_rows as i64,
num_deleted_rows: v.num_deleted_rows.map(|n| n as i64),
num_indices: v.num_indices as i64,
fragment_stats: FragmentStatistics {
num_fragments: v.fragment_stats.num_fragments as i64,