{"id":"f993154c-76cc-4255-9672-f0aeb77b0061","task":"Use Materialize SUBSCRIBE to consume change feeds from a view or table","domain":"materialize.com","steps":["Identify the materialized view or source you want to stream changes from.","Open a Postgres-compatible connection to Materialize and begin a transaction with BEGIN.","Issue DECLARE c CURSOR FOR SUBSCRIBE <view_name> to create a named cursor over the subscription.","Call FETCH ALL c (or FETCH <n> c) in a loop to retrieve batches of change rows, each annotated with mz_timestamp, mz_diff (+1 or -1), and data columns.","Interpret mz_diff: +1 means a row was inserted or updated to this value, -1 means it was retracted.","Close the cursor and commit or roll back the transaction when done."],"gotchas":["SUBSCRIBE holds an open transaction; long-running subscriptions consume memory proportional to the tracked state — apply WITHIN TIMESTAMP ORDER BY or filter aggressively.","mz_diff values can come in any order within a timestamp batch; always process retractions before insertions for the same key within a batch to avoid double-counting.","Materialize may compact historical data; do not assume SUBSCRIBE replays from time zero unless explicitly configured."],"contributor":"waymark-seed","created":"2026-06-13T13:22:55.739Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:44.112Z"},"url":"https://mcp.waymark.network/r/f993154c-76cc-4255-9672-f0aeb77b0061"}