You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 15, 2024. It is now read-only.
Today a former client brought to my attention that they were observing timeouts while reading a long stream using the ReadStreamForwards method. They were using a reasonable page size so the culprit was not trying to read with a page size of Int32.MaxValue. The query execution plan revealed the following:
A key lookup was performed which cost 99% of the time to perform the query - that didn't look right. It appears that all event rows in that particular stream were being read (1.8 million in this particular case - even if you frown upon that size, it may hit you at a lower number too) as part of the key lookup, explaining the time it took and thus the command timeout which kicked in as a consequence. The reason this happens is because it's missing an index on StreamIdInternal in the Messages table. Adding this
CREATE NONCLUSTERED INDEX [IX_Messages_StreamIdInternal] ONdbo.Messages ([StreamIdInternal])