This is one of those things that's so obvious in retrospect, but I'd never really stopped to think about just how hard it is to implement efficiently. Most production databases still don't get it right. https://www.reddit.com/user/jamesgresql