forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scenarios_scale.py
77 lines (65 loc) · 2.19 KB
/
scenarios_scale.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.
from textwrap import dedent
from materialize.feature_benchmark.measurement_source import MeasurementSource, Td
from materialize.feature_benchmark.scenario import Scenario
class SmallClusters(Scenario):
"""Materialized views across many small clusters."""
SCALE = 1.5 # 32 clusters
FIXED_SCALE = True
def benchmark(self) -> MeasurementSource:
create = "\n".join(
dedent(
f"""
> DROP CLUSTER IF EXISTS cluster{i} CASCADE;
> CREATE CLUSTER cluster{i} REPLICAS (r (SIZE '4-1'));
> CREATE MATERIALIZED VIEW v{i}
IN CLUSTER cluster{i}
AS SELECT COUNT(*) FROM t1;
> CREATE DEFAULT INDEX ON v{i}
"""
)
for i in range(self.n())
)
select = "\n".join(
dedent(
f"""
> SET CLUSTER = cluster{i}
> SELECT * FROM v{i}
100000
"""
)
for i in range(self.n())
)
return Td(
dedent(
f"""
> DROP TABLE IF EXISTS t1 CASCADE;
> CREATE TABLE t1 (f1 INTEGER);
$ postgres-execute connection=postgres://mz_system:materialize@${{testdrive.materialize-internal-sql-addr}}
ALTER SYSTEM SET max_clusters = {self.n() + 2};
"""
)
+ create
+ dedent(
"""
> INSERT INTO t1
SELECT * FROM generate_series(1, 100000)
/* A */
"""
)
+ select
+ dedent(
"""
> SELECT 1
/* B */;
1
"""
)
)