Module materialize.feature_benchmark.scenarios.customer

Expand source code Browse git
# 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.action import Action, TdAction
from materialize.feature_benchmark.measurement_source import MeasurementSource, Td
from materialize.feature_benchmark.scenario import Scenario


class CustomerWorkload1(Scenario):
    """Aggregation over a large non-monotonic source."""

    def init(self) -> Action:
        return TdAction(
            dedent(
                f"""
                > DROP TABLE IF EXISTS t1 CASCADE;

                > CREATE TABLE t1 (f1 INTEGER);

                > INSERT INTO t1 SELECT * FROM generate_series(1, {self.n()});
                """
            )
        )

    def benchmark(self) -> MeasurementSource:
        return Td(
            dedent(
                f"""
                > DROP MATERIALIZED VIEW IF EXISTS v1;

                > CREATE MATERIALIZED VIEW v1 AS SELECT MAX(f1) FROM t1
                  /* A */;

                > SELECT * FROM v1
                  /* B */;
                {self.n()}
                """
            )
        )

Classes

class CustomerWorkload1 (scale: float, mz_version: MzVersion, default_size: int, seed: int)

Aggregation over a large non-monotonic source.

Expand source code Browse git
class CustomerWorkload1(Scenario):
    """Aggregation over a large non-monotonic source."""

    def init(self) -> Action:
        return TdAction(
            dedent(
                f"""
                > DROP TABLE IF EXISTS t1 CASCADE;

                > CREATE TABLE t1 (f1 INTEGER);

                > INSERT INTO t1 SELECT * FROM generate_series(1, {self.n()});
                """
            )
        )

    def benchmark(self) -> MeasurementSource:
        return Td(
            dedent(
                f"""
                > DROP MATERIALIZED VIEW IF EXISTS v1;

                > CREATE MATERIALIZED VIEW v1 AS SELECT MAX(f1) FROM t1
                  /* A */;

                > SELECT * FROM v1
                  /* B */;
                {self.n()}
                """
            )
        )

Ancestors

Methods

def benchmark(self) ‑> MeasurementSource
Expand source code Browse git
def benchmark(self) -> MeasurementSource:
    return Td(
        dedent(
            f"""
            > DROP MATERIALIZED VIEW IF EXISTS v1;

            > CREATE MATERIALIZED VIEW v1 AS SELECT MAX(f1) FROM t1
              /* A */;

            > SELECT * FROM v1
              /* B */;
            {self.n()}
            """
        )
    )
def init(self) ‑> Action
Expand source code Browse git
def init(self) -> Action:
    return TdAction(
        dedent(
            f"""
            > DROP TABLE IF EXISTS t1 CASCADE;

            > CREATE TABLE t1 (f1 INTEGER);

            > INSERT INTO t1 SELECT * FROM generate_series(1, {self.n()});
            """
        )
    )

Inherited members