The same query returns different results when enable_material is changed:
CREATE TABLE t2(c1 DECIMAL, c2 serial); CREATE TABLE t4(c0 TEXT); INSERT INTO t2(c2) VALUES(1), (2); INSERT INTO t2(c1) VALUES(0.1); INSERT INTO t4(c0) VALUES('a'), ('b'), ('c');
SET enable_material=true; SELECT DISTINCT ON (t2.c1) t2.c2 FROM t2, t4; -- {1}, {1} SET enable_material=false; SELECT DISTINCT ON (t2.c1) t2.c2 FROM t2, t4; -- {1}, {2}
With DISTINCT ON, only the first row of each set is kept, which is unpredictable. Usually you're supposed to use ORDER BY to get the desired row.