Strategies for One-to-Many type of association where “many” side entries are in millions

喜夏-厌秋 提交于 2019-12-13 05:24:44

问题


Giving an analogy: Twitter like scenario where in a person can be followed by huge number of people (one-to-many) ,

Few options which I could think of

  1. Use some OR mapping tool with lazy loading. But when you access the "followers" side of relations, it will still load all the data even tough lazily. So not a suitable option.

  2. Do not maintain one-to-many relation (or not use any OR mapping) . Fetch the "Followers" side in separate call and handle the paging etc programmatically.

  3. Offload Fetching of large data to some search stack (Lucene/Solr) which can better handle large data. But this will introduce some latency between database update and index update.

Please share your thoughts/suggestions and any possible tools library. Stack consists of Java , MySQL.


回答1:


Millions should not be a problem for an RDBMS as it is designed for those situations.

Sometimes it is also recommended to denormalize rather than normalize to optimize the performance of your application. This is specifically for applications that have very high read and very low write statistics.



来源:https://stackoverflow.com/questions/9125301/strategies-for-one-to-many-type-of-association-where-many-side-entries-are-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!