-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add performance tuning tutorial and script
- Loading branch information
Showing
12 changed files
with
2,314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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("") |
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.
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
BIN
+286 KB
images/v2.0/perf_tuning_multi_region_rebalancing_after_partitioning.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.
Large diffs are not rendered by default.
Oops, something went wrong.