customer.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from textwrap import dedent
  10. from materialize.feature_benchmark.action import Action, TdAction
  11. from materialize.feature_benchmark.measurement_source import MeasurementSource, Td
  12. from materialize.feature_benchmark.scenario import Scenario
  13. class CustomerWorkload1(Scenario):
  14. """Aggregation over a large non-monotonic source."""
  15. def init(self) -> Action:
  16. return TdAction(
  17. dedent(
  18. f"""
  19. > DROP TABLE IF EXISTS t1 CASCADE;
  20. > CREATE TABLE t1 (f1 INTEGER);
  21. > INSERT INTO t1 SELECT * FROM generate_series(1, {self.n()});
  22. """
  23. )
  24. )
  25. def benchmark(self) -> MeasurementSource:
  26. return Td(
  27. dedent(
  28. f"""
  29. > DROP MATERIALIZED VIEW IF EXISTS v1;
  30. > CREATE MATERIALIZED VIEW v1 AS SELECT MAX(f1) FROM t1
  31. /* A */;
  32. > SELECT * FROM v1
  33. /* B */;
  34. {self.n()}
  35. """
  36. )
  37. )