all-things-risingwave

What is the impact of the ORDER BY clause in the CREATE MATERIALIZED VIEW statement?

I came across a note stating that the ORDER BY clause in the CREATE MATERIALIZED VIEW statement is allowed but not considered as part of the definition of the materialized view. It’s only used in the initial creation of the materialized view and not during refreshes. What does this mean for the ordering of results when querying the materialized view?

Ni

Nizar Hejazi

Asked on Jun 06, 2023

  1. The ORDER BY clause in the CREATE MATERIALIZED VIEW statement is used only during the initial creation of the materialized view and does not impact the ordering of results during refreshes.

  2. When querying the materialized view, the results are not returned in order by default.

  3. If you need ordered output when querying the materialized view, you should use the ORDER BY clause in your select query.

  4. The ORDER BY clause in the CREATE MATERIALIZED VIEW statement does not preserve order for new data; it only applies to historical data.

  5. Without an ORDER BY clause in the select query on the materialized view, there is no guarantee of the result set being ordered.

Jun 07, 2023Edited by