r/programming • • Feb 17 '16

Stack Overflow: The Architecture - 2016 Edition

http://nickcraver.com/blog/2016/02/17/stack-overflow-the-architecture-2016-edition/
1.7k Upvotes

461 comments sorted by

View all comments

Show parent comment

2

u/nickcraver Feb 18 '16

ROWVERISON is a sequence yeah, you can cast it as a BIGINT and in Elasticsearch we keep a single document with a "position" type that simply stores the highest one we saw on the last pass and a timestamp for kicks. That way Elasticsearch knows what position the index it contains is at; beign a self-contained info source on this is big. On the next pass we just select rows with a ROWVERSION > last position and index those - easy delta that SQL server managed by itself.

In other cases where related updated that affect the index aren't on that row (so ROWVERSION doesn't increment), or it has something like ViewCount we don't index...so it increment too often: we just have a LastChangeDate field we compare instead. And it's up to our code to set that when something that affects the index happens. The upcoming Developer Story feature has this setup with the story and sub-items in the story.