From 32d4a352dc45a3352408a46b691288c337c0d966 Mon Sep 17 00:00:00 2001 From: Nathan Coad Date: Wed, 21 Jan 2026 11:44:13 +1100 Subject: [PATCH] reduced the places where we probe hourly tables --- internal/tasks/inventoryHelpers.go | 14 ++------------ internal/tasks/inventoryLifecycle.go | 12 +++--------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/internal/tasks/inventoryHelpers.go b/internal/tasks/inventoryHelpers.go index 7aa086f..d362e1d 100644 --- a/internal/tasks/inventoryHelpers.go +++ b/internal/tasks/inventoryHelpers.go @@ -103,19 +103,9 @@ LIMIT ? continue } probed := false - hasRows := count.Valid && count.Int64 > 0 + // If count is known and >0, trust it; if NULL, accept optimistically to avoid heavy probes. + hasRows := !count.Valid || count.Int64 > 0 start := time.Now() - if !count.Valid { - probed = true - if ok, err := db.TableHasRows(ctx, dbConn, name); err == nil { - hasRows = ok - } else { - hasRows = false - if logger != nil { - logger.Debug("snapshot table probe failed", "table", name, "error", err) - } - } - } if vcenter != "" && hasRows { probed = true vrows, qerr := querySnapshotRows(ctx, dbConn, name, []string{"VmId"}, `"Vcenter" = ? LIMIT 1`, vcenter) diff --git a/internal/tasks/inventoryLifecycle.go b/internal/tasks/inventoryLifecycle.go index 1ac3a7b..f3e8037 100644 --- a/internal/tasks/inventoryLifecycle.go +++ b/internal/tasks/inventoryLifecycle.go @@ -137,15 +137,9 @@ ORDER BY snapshot_time ASC if err := db.ValidateTableName(t.Table); err != nil { continue } - if t.Count.Valid { - if t.Count.Int64 <= 0 { - continue - } - } else { - hasRows, err := db.TableHasRows(ctx, dbConn, t.Table) - if err != nil || !hasRows { - continue - } + // Trust snapshot_count if present; otherwise optimistically include to avoid long probes. + if t.Count.Valid && t.Count.Int64 <= 0 { + continue } tables = append(tables, t) }