internal/postgres: repeat search when grouping
internal/postgres: repeat search when grouping

When grouping results, search a second time with a larger limit if the
first doesn't return enough results.

Also, remove the Limit search option; it is an implementation detail
that should be determined by DB.Search.

I tested this against 176 distinct queries obtained from the logs over
a 1-hour period, with max results = 10. Although it was somewhat
slower than without grouping, the 99%ile was still under 1 second.

For golang/go#47320

Change-Id: Ie09d6b83bc270a7113abd74b03daf26fa6054b0f
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/336950
Trust: Jonathan Amsterdam <e3d3698b2ccd5955e4adf250d0785062d0f9018b@google.com>
Run-TryBot: Jonathan Amsterdam <e3d3698b2ccd5955e4adf250d0785062d0f9018b@google.com>
Reviewed-by: Jamal Carvalho <e0195770807aa8c82b0b128d9c0423b5ad035172@golang.org>
Reviewed-by: Julie Qiu <8d32267b6b4884cf35adeaccde2b6857ae11aace@golang.org>
TryBot-Result: kokoro <2ac7b1f3fa578934c95181d4272be0d3bca00121@google.com>

golang/pkgsite,golang/pkgsite,golang/pkgsite,golang/pkgsite