diff --git a/lib/storage/index_db.go b/lib/storage/index_db.go
index ca82109ac2..05fe9dcc6c 100644
--- a/lib/storage/index_db.go
+++ b/lib/storage/index_db.go
@@ -1727,6 +1727,15 @@ func (is *indexSearch) updateMetricIDsForOrSuffixWithFilter(prefix []byte, metri
 		}
 		metricID := encoding.UnmarshalUint64(v)
 		if metricID != nextMetricID {
+			// Skip metricIDs smaller than the found metricID, since they don't
+			// match anything.
+			if len(sortedFilter) > 0 && metricID > sortedFilter[0] {
+				sortedFilter = sortedFilter[1:]
+				n := sort.Search(len(sortedFilter), func(i int) bool {
+					return metricID <= sortedFilter[i]
+				})
+				sortedFilter = sortedFilter[n:]
+			}
 			continue
 		}
 		if isNegative {