r/programming • u/nickcraver • 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
r/programming • u/nickcraver • Feb 17 '16
View all comments
Show parent comment
2
u/nickcraver Feb 18 '16
ROWVERISONis a sequence yeah, you can cast it as aBIGINTand 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 aROWVERSION> 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
ROWVERSIONdoesn't increment), or it has something likeViewCountwe don't index...so it increment too often: we just have aLastChangeDatefield 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.