aboutsummaryrefslogtreecommitdiff
path: root/internal/postgres/postgres.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2019-09-24 15:20:57 -0400
committerJulie Qiu <julie@golang.org>2020-03-27 16:46:43 -0400
commitb0cdd8a50f07b31b535cc2a4d72668c3a6b929bf (patch)
treee175d32f7f0535e33d68b580c9c043d5760a149c /internal/postgres/postgres.go
parent966b71c013cfd584ba7d7313bc7865b619c13580 (diff)
downloadgo-x-pkgsite-b0cdd8a50f07b31b535cc2a4d72668c3a6b929bf.tar.xz
internal/postgres: add a search benchmark
A search benchmark is added, to be run against a dev instance of the database. Updates b/141182438 Change-Id: I73e9742cc6697f282a84252ab85b85d7dc0c689f Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/556705 CI-Result: Cloud Build <devtools-proctor-result-processor@system.gserviceaccount.com> Reviewed-by: Julie Qiu <julieqiu@google.com> Reviewed-by: Jonathan Amsterdam <jba@google.com>
Diffstat (limited to 'internal/postgres/postgres.go')
-rw-r--r--internal/postgres/postgres.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/postgres/postgres.go b/internal/postgres/postgres.go
index 32d9a35a..220a2b5f 100644
--- a/internal/postgres/postgres.go
+++ b/internal/postgres/postgres.go
@@ -45,9 +45,15 @@ func (db *DB) queryRow(ctx context.Context, query string, args ...interface{}) *
return db.db.QueryRowContext(ctx, query, args...)
}
-var queryCounter int64 // atomic: per-process counter for unique query IDs
+var (
+ queryCounter int64 // atomic: per-process counter for unique query IDs
+ queryLoggingDisabled bool // For use in benchmarks only: not concurrency-safe.
+)
func logQuery(query string, args []interface{}) func(*error) {
+ if queryLoggingDisabled {
+ return func(*error) {}
+ }
const maxlen = 300 // maximum length of displayed query
// To make the query more compact and readable, replace newlines with spaces