compaction.td 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #
  10. # Smoke tests that verify compaction occurs as expected.
  11. #
  12. # Right now this test only verifies that user tables are hooked up together properly
  13. # and will compact stored data. There's more detailed tests that check exactly
  14. # how the persist codebase does compaction in src/persist.
  15. $ set-sql-timeout duration=30s
  16. > CREATE MATERIALIZED VIEW most_recent_mz_metrics AS
  17. SELECT * FROM
  18. (SELECT DISTINCT metric FROM mz_metrics) grp,
  19. LATERAL (
  20. SELECT value FROM mz_metrics
  21. WHERE metric = grp.metric
  22. ORDER BY time DESC LIMIT 1)
  23. > CREATE TABLE compaction (f1 TEXT);
  24. # At the beginning there's fewer than 200 bytes in the stored arrangement.
  25. > SELECT value < 200 AS result FROM most_recent_mz_metrics where metric = 'mz_persist_trace_blob_bytes'
  26. result
  27. -----
  28. true
  29. # Insert over 1 MiB of data.
  30. > INSERT INTO compaction VALUES (repeat('this is a compaction test. ', 50000));
  31. # There's at least 1 MiB in the stored arrangement.
  32. > SELECT value > 1 << 20 AS result FROM most_recent_mz_metrics where metric = 'mz_persist_trace_blob_bytes'
  33. result
  34. -----
  35. true
  36. # Delete all the values from the table.
  37. > DELETE FROM compaction;
  38. # After deletion and compaction there's fewer than 200 bytes in the stored arrangement.
  39. > SELECT value < 200 AS result FROM most_recent_mz_metrics where metric = 'mz_persist_trace_blob_bytes'
  40. result
  41. -----
  42. true