SQL API获取全部并查询还是查询数据库? [英] SQL API Get All and Query or Query Database?

查看:197
本文介绍了SQL API获取全部并查询还是查询数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定在我正在处理的数据库上处理数据的最佳方法.我有一个选项可以从集合中获取所有数据,然后在该列表上使用Linq.另一个选项是在Azure.Documents.Client附带的IQueryable上使用Linq 我假设在Cosmos一侧处理数据.

哪个会使用更多RU/s?将所有文档获取到列表然后进行处理会发送大量数据,但在Cosmos方面使用少量的处理能力,而在数据库上进行处理则会在Cosmos上使用很多处理能力 端,但不会发送回大量数据.

很明显,随着应用程序的扩展和集合中数据的增加,我将需要制定一种解决方案,以免删除整个数据库,并且一次仅删除一部分,以免填满服务器RAM.

另一个值得注意的用例是后台任务,其中我将计算满足特定条件的项目.第二个条件是根据HTTP请求的过滤器和登录的用户为其提供数据.

< style>< br _moz_dirty =" /></style>

解决方案

里卡多,

列表中的数据是静态数据还是任何文档属性是动态的(预期将来会有更新),并且需要对列表进行频繁的更新才能使客户端列表(或缓存)保持最新状态?

如果列表是静态的,则在较长的时间内,最初拉所有"文档并使用客户端缓存进行排序而不是再次调用相同的文档+属性,可能会更具成本效益. /p>

请注意,基于您的R/U配置,Azure Cosmos DB SDK将以批处理方式遍历所有返回的文档.客户端不会在一次调用中获得所有返回的文档.

如果您还有其他疑问,请告诉我们.

此致

迈克


Not sure the best way to go about processing data on a database I am working on. I have one option to get all of the data from the collection and then use Linq on that list. The other option is to use Linq on the IQueryable that comes with Azure.Documents.Client which I assume processes the data on the Cosmos side.

Which one will use more RU/s? The getting of all of the documents to a list then processing them sends a lot of data but uses a small amount of processing power on the Cosmos side and processing on the database uses a lot of processing power on the Cosmos side but doesn't send a huge amount of data back.

Obviously as the application scales and there is more data in the collections I will need to work out a solution to not take down the entire database and only parts at a time as to not fill up the servers RAM.

Also worth noting one use case is a background task, where I would be counting items that meet a certain criteria. The second criteria would be serving HTTP requests with data based on their filters and the logged in user.

<style><br _moz_dirty="" /></style>

解决方案

Hi Ricardo,

Is the data in the list static data or are any document properties dynamic (future updates anticipated), and frequent updates to the list are required to keep a client list (or cache) up to date? 

If the list is static, it might be more cost effective, over a longer term duration, to pull 'all' documents initially and use a client-side cache to sort through instead of calling the same document + properties again.

Please be aware that based upon your R/U configuration, the Azure Cosmos DB SDKs will iterate through all returned documents in a batch fashion. The client will not get all documents returned in a single call. 

Please let us know if you have any additional questions.

Regards,

Mike


这篇关于SQL API获取全部并查询还是查询数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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