Syntax
Parameters
READ_SNAPSHOT records the load in the stream’s position of record, in the transaction of the statement that runs it, so it has to run inside a writing statement such as INSERT INTO ... SELECT. A stream attached to a CDC table cannot be loaded this way, since the table owns the stream. A statement reads a MongoDB stream at most once, counting READ_STREAM and READ_SNAPSHOT together and a WITH query once per reference, because each read stores the stream’s whole position. A view cannot read a MongoDB stream.
How the load lines up with the change feed
- Postgres: the scan reads a snapshot taken from a temporary replication slot and moves the stream’s position to that snapshot.
READ_STREAMafterwards returns exactly the transactions the snapshot does not contain. - MongoDB: the load moves the stream’s position to where the change feed was just before the scan. The scan is not a point-in-time read, but applying the change feed after the load converges anyway, because every change carries the whole document. Changes made during the scan can appear both in the load and in the feed. Since the load needs no stored position, it also rebuilds a stream whose position has aged out of the oplog.