CREATE TABLE test AS
	SELECT * FROM generate_series(1, 10) AS f (col) ORDER BY random();
CREATE MATERIALIZED VIEW m_test AS SELECT * FROM test ORDER BY col;
CREATE UNIQUE INDEX i_test ON m_test (col);

SELECT * FROM m_test;
UPDATE test SET col = 13 WHERE col = 3;

REFRESH MATERIALIZED VIEW m_test;
UPDATE test SET col = 14 WHERE col = 4;

REFRESH MATERIALIZED VIEW CONCURRENTLY m_test;
SELECT * FROM m_test;

UPDATE test SET col = 4 WHERE col = 14;

REFRESH MATERIALIZED VIEW CONCURRENTLY m_test;
SELECT * FROM m_test;

REFRESH MATERIALIZED VIEW m_test;
SELECT * FROM m_test;
