From 1b802539ef16d013ae1544257a61b6520f3c817f Mon Sep 17 00:00:00 2001 From: Martin Hutchinson Date: Tue, 21 Nov 2023 14:11:25 +0000 Subject: [PATCH] Skip SELECTing revision that isn't used (#3207) This is a minor cleanup but it simplifies #3201 to avoid reading this, and pulling out this change to the existing logic into its own PR simplifies review. --- storage/mysql/tree_storage.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/storage/mysql/tree_storage.go b/storage/mysql/tree_storage.go index b09c3fcfe6..c9bae1b5a4 100644 --- a/storage/mysql/tree_storage.go +++ b/storage/mysql/tree_storage.go @@ -39,7 +39,7 @@ const ( VALUES(?,?,?,?,?,?)` selectSubtreeSQL = ` - SELECT x.SubtreeId, x.MaxRevision, Subtree.Nodes + SELECT x.SubtreeId, Subtree.Nodes FROM ( SELECT n.TreeId, n.SubtreeId, max(n.SubtreeRevision) AS MaxRevision FROM Subtree n @@ -223,9 +223,8 @@ func (t *treeTX) getSubtrees(ctx context.Context, treeRevision int64, ids [][]by for rows.Next() { var subtreeIDBytes []byte - var subtreeRev int64 var nodesRaw []byte - if err := rows.Scan(&subtreeIDBytes, &subtreeRev, &nodesRaw); err != nil { + if err := rows.Scan(&subtreeIDBytes, &nodesRaw); err != nil { klog.Warningf("Failed to scan merkle subtree: %s", err) return nil, err }