Yes, we've done this in the past, but the implementation was always wrong. Changes to the approach this time around:
1) it's not required. if it won't work, it falls back quickly to old algorithm.
2) it doesn't tax the database. very simple schema, and all the real bookkeeping is done in perl (on the cheap webservers), not in the database. there's even a parameter to adjust how often cache updates happen
3) an out-of-date cache (if aforementioned parameter is set to non-zero) still helps the old algorithm. so any cache is good.
The patch is here, for those curious:
I've been testing this for a number of hours this evening, and I'm relatively convinced it works, but the friends view code is some of the trickiest/ugliest in the codebase, so I made it an option for now. If you want to enable it, visit:
Note: the optimization only affects when you're logged in and looking at your own friends view without any filters.
Update: newest code live, 3 bugs squished. if your cache is corrupt/old, turn beta testing on again to clear it.... then test out for a few hours before reporting any bugs.