Efficient way to implement LinkedIn like “How you are connected to” feature?

前端 未结 2 1182
Happy的楠姐
Happy的楠姐 2021-01-31 23:06

LinkedIn has this cool feature in which while visiting some user\'s profile, LinkedIn prompts how you are connecting to that user through the network.

Assuming that the

2条回答
  •  自闭症患者
    2021-01-31 23:41

    Without some kind of recursive stored procedure (CTE in SQL Server 2005+), you'll need multiple round trips as the levels get deeper. However, a good cache infrastructure could really help performance as the most popular / active users' connection lists would remain cached. A read/write through cache mechanism would make things even better (cache updates cascade to db updates, cache reads cascade to db reads)

提交回复
热议问题