Skip to content

Commit

Permalink
Add benchmark code for spanner subquery (GoogleCloudPlatform#587)
Browse files Browse the repository at this point in the history
* Add benchmark code for spanner subquery

* Update toplevel README

* Apply suggestions from code review

Co-authored-by: Jacob Ferriero <jferriero@google.com>

* Fix README and benchmark pattern

* Add how to stop benchmark

Co-authored-by: Jacob Ferriero <jferriero@google.com>
  • Loading branch information
2 people authored and rosmo committed Mar 17, 2022
1 parent c42b0ea commit e834a08
Show file tree
Hide file tree
Showing 6 changed files with 749 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The examples folder contains example solutions across a variety of Google Cloud
* [Pub/Sub Client Batching Example](examples/pubsub-publish-avro-example) - Batching in Pub/Sub's Java client API.
* [QAOA](examples/qaoa) - Examples of parsing a max-SAT problem in a proprietary format.
* [Redis Cluster on GKE Example](examples/redis-cluster-gke) - Deploying Redis cluster on GKE.
* [Spanner Interleave Subquery](examples/spanner-interleave-subquery) - Example code to benchmark Cloud Spanner's subqueries for interleaved tables.
* [Spinnaker](examples/spinnaker) - Example pipelines for a Canary / Production deployment process.
* [TensorFlow Serving on GKE and Load Testing](examples/tf-load-testing) - Examples how to implement Tensorflow model inference on GKE and to perform a load testing of such solution.
* [TensorFlow Unit Testing](examples/tensorflow-unit-testing) - Examples how to write unit tests for TensorFlow ML models.
Expand Down
29 changes: 29 additions & 0 deletions examples/spanner-interleave-subquery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# spanner-interleave-subquery

This example contains the benchmark code to examine query efficiency gains of using Cloud Spanner interleaved tables with subqueries.

## Prerequisite

Run the following command to create a Cloud Spanner database with [schema.sql](schema.sql).

```bash
gcloud spanner databases create ${DATABASE} --instance=${INSTANCE} --ddl-file=schema.sql
```

## How to run the benchmark

Run the following command. You might need Go 1.15 or higher.

```bash
go run main.go --project=${PROJECT} --instance=${INSTANCE} --database=${DATABASE} --pattern=${PATTERN} --parallel=${PARALLEL}
```

For `--pattern` flag please specify the following number.

1. Insert sample data.
2. Run benchmark with separated queries for interleaved tables.
3. Run benchmark with subqueries for interleaved tables.

You might need to run `--pattern=1` prior to running the benchmark for `--pattern=2` or `--pattern=3` to insert sample data.

Note that this benchmark runs forever unless you stop the process by Ctr+C (SIGINT).
9 changes: 9 additions & 0 deletions examples/spanner-interleave-subquery/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/GoogleCloudPlatform/professional-services/examples/spanner-interleave-subquery

go 1.15

require (
cloud.google.com/go/spanner v1.12.0
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
google.golang.org/api v0.36.0
)
Loading

0 comments on commit e834a08

Please sign in to comment.