如何处理大型对象? [英] How to deal with large objects?

查看:110
本文介绍了如何处理大型对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5个类型的对象:地方信息(14属性),业主公司信息(5个属性),图片,评级(存储多个投票结果),注释

I have 5 types of objects: place info (14 properties),owner company info (5 properties), picture, ratings (stores multiple vote results), comments.

所有这些5个对象将聚集,使一个对象(地方),将有关于该地点的所有信息,图片,评论等。

All those 5 objects will gather to make one object (Place) which will have all the properties and information about all the Place's info, pictures, comments, etc

我试图做到的,是有显示的地方对象的页面和所有它的属性。另外一个问题,如果我想显示的业主公司的个人资料我得对象为每个业主公司(但我会添加第六财产是他们所拥有的所有地点的列表)

What I'm trying to achieve is to have a page that displays the place object and all it's properties. another issue, if I want to display the Owner Companies' profiles I'll have object for each owner company (but I'll add a sixth property which is a list of all the places they own)

我已经练了一段时间,但我从来没有进入实施和演出经验,但我感觉到,这是太过分了!

I've been practicing for a while, but I never got into implementing and performance experience, but I sensed that it was too much!

你觉得呢?

What do you think ?

推荐答案

您必须检查您的解决方案用例场景。你需要始终表现出所有的数据,或者你只显示它的一部分出发?有可能扩大的任何折叠的项目,如经常使用的部分用户或此信息只在不常见的用途使用?

You have to examine the use case scenarios for your solution. Do you need to always show all of the data, or are you starting off with displaying only a portion of it? Are users likely to expand any collapsed items as part of regular usage or is this information only used in less common usages?

根据的回答可能是最好的获取和同时处理所有的数据填充整个页面,或者它可以是只需要一些数据来呈现初始屏幕和其余的可以拿来的情况下的按需

Depending on your answers it may be best to fetch and populate the entire page with all of the data at once, or it may be the case that only some data is needed to render the initial screen and the rest can be fetched on-demand.

在大多数情况下,最好的解决方案可能涉及获取仅所需要的数据和动态使用AJAX查询根据需要更新页面。

In most cases the best solution is likely to involve fetching only the required data and to update the page dynamically using ajax queries as needed.

至于优化数据访问,需要求取数据库的请求的数目和每个单独的请求的复杂性之间的平衡。由于网络延迟的往往是重要的,使用尽可能少的查询成为可能,即使这意味着你有时可以获取,你并不总是需要的数据,尽可能获取。但是,如果您在一个查询太多的数据,然后计算所有的联接也可能是昂贵的。这是相当难得看到一个解决方案,其中最好是先提取所有根对象,然后对每一个元素拿来与该元素相关的一些其他对象。因此,设计解决方案时获取一次所有数据,但只包括你真正需要的,并尝试参与表的数量保持在最低限度。

As for optimizing data access, you need to strike a balance between the number of database requests and the complexity of each individual request. Because of network latency it is often important to fetch as much as possible using as few queries as possible, even if this means you'll sometimes be fetching data that you do not always need. But if you include too much data in a single query, then computing all the joins may also be costly. It is quite rare to see a solution in which it is better to first fetch all root objects and then for every element go fetch some additional objects associated with that element. As such, design your solution to fetch all data at once, but include only what you really need and try to keep the number of involved tables to a minimum.

这篇关于如何处理大型对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆