Know when rows are ready for select?

For a particular table, it is always the case that writerTxn <= sequencerTxn.

sequencerTxn tells you how many transactions are committed (inserted to database).
writerTxn tells you how many transactions are applied (visible for read).

  • INSERT data A
  • Tick wal_tables() and assign sequencerTxn_a to the insert.
  • SELECT data A query tagged with sequencerTxn_a.
  • Wait until tick has passed.
  • Tick wal_tables() and read writerTxn_b.
  • If writerTxn_b >= sequencerTxn_a then run the query.
  • Otherwise wait for another tick.
  • Repeat.

You can get more granular data from the sys.telemetry_wal table, which has deeper info on when things happened, how long they took. This is the table that feeds the metrics charts on the web console.

But wal_tables() is simplest to start with!

1 Like