非常复杂的数据库架构,如何处理?
我曾经开发过多个 Rails 应用程序,现在我从数据库方面开发一个非常复杂的应用程序。很多嵌套模型,几个多态关联......
你如何处理这种复杂性?我怎么知道我们正在朝着好的方向努力?性能问题怎么办?
感谢您的意见。
I have worked on several rails applications and now I work on a very complex one, from the database side. A lots of nested models, several polymorphyc associations...
How you deal with that complexity ? How can I know that we are working in the good direction ? What about performance issues ?
Thansk for your opinions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您需要估计应用程序针对数据库运行的查询的性能。然后您可以尝试优化查询,例如通过添加一些索引。也许在某些情况下,您还需要考虑对某些数据进行非规范化以获得更好的性能。
查询的性能还可能取决于您的数据大小。如果您有非常大的数据集并且查询是最佳的,那么您可以考虑引入(分布式)缓存。或者,如果数据模型允许,请考虑将数据库分区到多个节点上以提高查询性能。
但第一步仍然应该是设置一些 SQL 查询性能监控。
First of all, you need to estimate the performance of the queries that your application runs against the database. Then you can try to optimize the queries, for example, by adding some indexes. Maybe in some cases you will also need to consider denormalizing some data to get better performance.
Performance of the queries may also depend on your data size. If you have really big data set and queries are optimal, then you may consider introducing (distributed) caching. Or if data model allows that think of partitioning your database on several nodes to improve query performance.
But still the first step should be a setup of some SQL query performance monitoring.
您应该考虑 NOSQL 解决方案,例如 MongoDB 或 CouchDB。有时,RDBMS 并不是完成这项工作的正确工具。
http://www.mongodb.org/
http://couchdb.apache.org/
You should consider a NOSQL solution such as MongoDB or CouchDB. Sometimes an RDBMS is not the right tool for the job.
http://www.mongodb.org/
http://couchdb.apache.org/