Sql-server – Indexed view – time of update

nullsql servert-sql

A 3rd part app is using 'our' database views. Basically flow looks like this:

  1. New Row is inserted to Results table;
  2. Insert new row to Event table (with information about new result).

The 3rd part is saying that sometimes they receive an event (also indexed view) but when they check indexed view for result it returns null. Asked programmers if that situation is possible from code side, they said it is not possible because the program wait with inserting row to Event table until result is finally saved (committing transaction).

From timestamps I see it takes ms from Result to Event. Like Result is saved at .320 and Event is saved at .350.

So my question is: Is it possible that it take so much time for indexed views to be actualized or maybe they are being actualized during insert statement?

Best Answer

No, an indexed view is maintained immediately as the base table is changed - there is no delay possible (unless the reader is using nolock and the original transaction hasn't committed yet). There must be something else going on, but you'll need to provide more details than "they said."