Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance tuning tutorial #3378

Merged
merged 1 commit into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions _includes/sidebar-data-v2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,12 @@
"/${VERSION}/performance-benchmarking-with-tpc-c.html"
]
},
{
"title": "Performance Tuning",
"urls": [
"/${VERSION}/performance-tuning.html"
]
},
{
"title": "Access Management",
"items": [
Expand Down
56 changes: 56 additions & 0 deletions _includes/v2.0/performance/tuning.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python

import argparse
import psycopg2
import time

parser = argparse.ArgumentParser(
description="test performance of statements against movr database")
parser.add_argument("--host", required=True,
help="ip address of one of the CockroachDB nodes")
parser.add_argument("--statement", required=True,
help="statement to execute")
parser.add_argument("--repeat", type=int,
help="number of times to repeat the statement", default = 20)
parser.add_argument("--times",
help="print time for each repetition of the statement", action="store_true")
parser.add_argument("--cumulative",
help="print cumulative time for all repetitions of the statement", action="store_true")
args = parser.parse_args()

conn = psycopg2.connect(database='movr', user='root', host=args.host, port=26257)
conn.set_session(autocommit=True)
cur = conn.cursor()

times = list()
for n in range(args.repeat):
start = time.time()
statement = args.statement
cur.execute(statement)
if n < 1:
if cur.description is not None:
colnames = [desc[0] for desc in cur.description]
print("")
print("Result:")
print(colnames)
rows = cur.fetchall()
for row in rows:
print([str(cell) for cell in row])
end = time.time()
times.append((end - start)* 1000)

cur.close()
conn.close()

print("")
if args.times:
print("Times (milliseconds):")
print(times)
print("")
print("Average time (milliseconds):")
print(float(sum(times))/len(times))
print("")
if args.cumulative:
print("Cumulative time (milliseconds):")
print(sum(times))
print("")
Binary file added images/v2.0/perf_tuning_concepts1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_concepts4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_movr_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/v2.0/perf_tuning_multi_region_topology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,271 changes: 2,271 additions & 0 deletions v2.0/performance-tuning.md

Large diffs are not rendered by default.