storage/db: optimize query terms matching "upload"

Since the upload ID is part of the primary key, we can avoid using the
RecordLabels table to find matching records. This takes the query
"upload:20170127.22 name:Gzip" from ~0.3s to ~0.04s on our production
database.

Change-Id: Id31624ec1b81f3a7f648c6597392718c56a10edd
Reviewed-on: https://go-review.googlesource.com/37236
Run-TryBot: Quentin Smith <quentin@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
3 files changed