Skip to content

Commit 0dfae65

Browse files
committed
feature-benchmark: add a pushdown benchmark
1 parent ba502e0 commit 0dfae65

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

misc/python/materialize/feature_benchmark/scenarios/benchmark_main.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,52 @@ def benchmark(self) -> MeasurementSource:
117117
""")
118118

119119

120+
class ProjectionPushdown(Scenario):
121+
"""Hydrate an MV that reads one column from a 32-column persist table.
122+
123+
Exercises parquet ProjectionMask pushdown: persist's decoder skips the 31
124+
columns the MV does not demand. Requires the
125+
`storage_source_enable_column_projection` dyncfg, which `init()` enables.
126+
"""
127+
128+
SCALE = 5
129+
130+
def init(self) -> list[Action]:
131+
return [
132+
TdAction("""
133+
$ postgres-connect name=mz_system url=postgres://mz_system:materialize@${testdrive.materialize-internal-sql-addr}
134+
$ postgres-execute connection=mz_system
135+
ALTER SYSTEM SET storage_source_enable_column_projection = true;
136+
137+
> CREATE CLUSTER pp_cluster SIZE 'scale=1,workers=16', REPLICATION FACTOR 1
138+
"""),
139+
]
140+
141+
def benchmark(self) -> MeasurementSource:
142+
n = self.n()
143+
column_defs = ", ".join(f"f{i} INTEGER" for i in range(32))
144+
select_cols = ", ".join(
145+
f"((generate_series * {17 + i * 7}) % 1000003)::int AS f{i}"
146+
for i in range(32)
147+
)
148+
return Td(f"""
149+
> DROP TABLE IF EXISTS pp_wide CASCADE
150+
> CREATE TABLE pp_wide ({column_defs})
151+
> INSERT INTO pp_wide SELECT {select_cols} FROM generate_series(1, {n})
152+
> ALTER CLUSTER pp_cluster SET (REPLICATION FACTOR 0)
153+
> CREATE MATERIALIZED VIEW pp_narrow IN CLUSTER pp_cluster AS SELECT f0 FROM pp_wide
154+
> SET CLUSTER = pp_cluster
155+
> SELECT 1
156+
/* A */
157+
1
158+
> ALTER CLUSTER pp_cluster SET (REPLICATION FACTOR 1)
159+
> SELECT COUNT(*) FROM pp_narrow
160+
/* B */
161+
{n}
162+
> SET CLUSTER = default
163+
""")
164+
165+
120166
class FastPathFilterIndex(FastPath):
121167
"""Measure the time it takes for the fast path to filter our all rows from a materialized view using an index and return"""
122168

0 commit comments

Comments
 (0)