storage: use interpolateParams to reduce Cloud SQL roundtrips

The MySQL protocol and database/sql require several round-trips to
execute queries with placeholders. Setting interpolateParams will
cause the mysql client library to interpolate the arguments and issue
a single string query to the server, reducing the number of round
trips. See
https://www.vividcortex.com/blog/2014/11/19/analyzing-prepared-statement-performance-with-vividcortex/

Change-Id: I766d593e9981c7ce2fbb1b48fe919ab46699416c
Reviewed-on: https://go-review.googlesource.com/35264
Reviewed-by: Russ Cox <rsc@golang.org>
diff --git a/storage/appengine/app.go b/storage/appengine/app.go
index d948f81..ca69ecf 100644
--- a/storage/appengine/app.go
+++ b/storage/appengine/app.go
@@ -29,7 +29,7 @@
 		dbName         = mustGetenv("CLOUDSQL_DATABASE")
 	)
 
-	return db.OpenSQL("mysql", fmt.Sprintf("%s:%s@cloudsql(%s)/%s", user, password, connectionName, dbName))
+	return db.OpenSQL("mysql", fmt.Sprintf("%s:%s@cloudsql(%s)/%s?interpolateParams=true", user, password, connectionName, dbName))
 }
 
 func mustGetenv(k string) string {
diff --git a/storage/cmd/reindex/reindex.go b/storage/cmd/reindex/reindex.go
index 25d5037..e18a5c6 100644
--- a/storage/cmd/reindex/reindex.go
+++ b/storage/cmd/reindex/reindex.go
@@ -29,7 +29,7 @@
 )
 
 var (
-	dbName  = flag.String("db", "root:@cloudsql(golang-org:us-central1:golang-org)/perfdata", "connect to MySQL `database`")
+	dbName  = flag.String("db", "root:@cloudsql(golang-org:us-central1:golang-org)/perfdata?interpolateParams=true", "connect to MySQL `database`")
 	bucket  = flag.String("bucket", "golang-perfdata", "read from Google Cloud Storage `bucket`")
 	verbose = flag.Bool("v", false, "verbose")
 )
diff --git a/storage/db/dbtest/dbtest.go b/storage/db/dbtest/dbtest.go
index 027425c..c003bba 100644
--- a/storage/db/dbtest/dbtest.go
+++ b/storage/db/dbtest/dbtest.go
@@ -43,7 +43,7 @@
 
 	t.Logf("Using database %q", name)
 
-	return prefix + name, func() {
+	return prefix + name + "?interpolateParams=true", func() {
 		if _, err := db.Exec(fmt.Sprintf("DROP DATABASE `%s`", name)); err != nil {
 			t.Error(err)
 		}