Skip to content

Commit d099e8e

Browse files
authored
Merge pull request #147 from ipfs/fix/optimize-naive-query
fix: avoid filtering by prefix unless necessary
2 parents ac8b6e6 + ec27f41 commit d099e8e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

query/query_impl.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ func NaiveQueryApply(q Query, qr Results) Results {
129129
}
130130
prefix = path.Clean(prefix)
131131
}
132-
// If the prefix isn't "/", end it in a "/" so we only find keys
133-
// _under_ the prefix.
132+
// If the prefix is empty, ignore it.
134133
if prefix != "/" {
135-
prefix += "/"
134+
qr = NaiveFilter(qr, FilterKeyPrefix{prefix + "/"})
136135
}
137-
qr = NaiveFilter(qr, FilterKeyPrefix{prefix})
138136
}
139137
for _, f := range q.Filters {
140138
qr = NaiveFilter(qr, f)

0 commit comments

Comments
 (0)