获取值了DynamoDB的 [英] Getting values out of DynamoDB

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

问题描述

我刚刚开始寻找到亚马逊DynamoDB。显然,可扩展性提出上诉,但我试图让我的头从SQL模式并进入无SQL模式。可以这样做(与dynamodb所有的可扩展性优势):

有条目的负载(比如5 - 10元)收录的一些数字。之一中的每个条目的字段将是一个创建日期。是否有一个有效途径发电机分贝给我的web应用程序的所有两个日期之间创建的条目?

有一个更简单的问题 - 能发电机分贝给我所有在该场比赛一定数量的条目。也就是说,就会有另外一个字段是一个数字,为​​了便于讨论让说0到10之间我能问dynamodb给我所有这一切都值如条目6?

执行这两个查询需要整个数据集的扫描(我以为是给定数据集大小的问题?)

非常感谢

解决方案
  

是否有一个有效途径发电机分贝给我的web应用程序的所有   两个日期之间创建的条目?

是啊,请看看的的<一个href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/DataModel.html#DataModelPrimaryKey">Primary在关键概念的亚马逊DynamoDB数据模型的,特别是哈希和范围类型主键的:

  

在这种情况下,主键由两个属性。第一   属性是散列属性,第二个是范围   属性。亚马逊DynamoDB建立在散的无序哈希索引   主键属性和范围主要排序的一系列指标   关键属性。 [...]

所列样本功能的使用情况完全,即回复(ID,ReplyDateTime,...)的表有利于类型的主键的哈希和范围的用哈希属性的编号的和各种属性的 ReplyDateTime 的。

您会通过<一个使用此href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_Query.html">Query API,看的 RangeKeyCondition 的详细信息和<一个href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/queryingdynamodb.html">Querying在亚马逊DynamoDB表了解各自的例子。

  

可以发电机分贝给我所有在该场比赛有一定的条目   数。 [...]我可以问dynamodb给   我所有这一切都值例如条目6?

这是可能的,尽管通过扫描 API只(即要求读表中确实每个项目),看的 ScanFilter 的详细信息和<一个href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/scandynamodb.html">Scanning在亚马逊DynamoDB表了解各自的例子。

  

执行这两个查询需要整个数据集的扫描(我   假定是给定数据集大小的问题吗?)

正如所提到的第一种方法适用于一个的查询的,而第二个要求的扫描的,并通常,一个查询操作比扫描操作更高效的 - 这是一个善意的提醒上手,虽然细节比较复杂,取决于你的使用情况,请参阅在<一个部分的扫描和查询性能的href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query和扫描亚马逊DynamoDB 概述:

  

有关更快的响应时间,设计出可以使用的方式你的表   查询,获取,或BatchGetItem的API,而不是。或者,设计   应用程序在影响最小的方式使用扫描操作   在你的桌面的请求速率。欲了解更多信息,请参阅<一href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/BestPractices.html">Provisioned在亚马逊DynamoDB 吞吐量准则。

所以,像往常一样将NoSQL的解决方案时,您可能需要调整您的架构以适应这些约束。

I've just started looking into Amazon's DynamoDB. Obviously the scalability appeals, but I'm trying to get my head out of SQL mode and into no-sql mode. Can this be done (with all the scalability advantages of dynamodb):

Have a load of entries (say 5 - 10 million) indexed by some number. One of the fields in each entry will be a creation date. Is there an effective way for dynamo db to give my web app all the entries created between two dates?

A more simple question - can dynamo db give me all entries in which a field matches a certain number. That is, there'll be another field that is a number, for argument's sake lets say between 0 and 10. Can I ask dynamodb to give me all the entries which have value e.g. 6?

Do both of these queries need a scan of the entire dataset (which I assume is a problem given the dataset size?)

many thanks

解决方案

Is there an effective way for dynamo db to give my web app all the entries created between two dates?

Yup, please have a look at the of the Primary Key concept within Amazon DynamoDB Data Model, specifically the Hash and Range Type Primary Key:

In this case, the primary key is made of two attributes. The first attributes is the hash attribute and the second one is the range attribute. Amazon DynamoDB builds an unordered hash index on the hash primary key attribute and a sorted range index on the range primary key attribute. [...]

The listed samples feature your use case exactly, namely the Reply ( Id, ReplyDateTime, ... ) table facilitates a primary key of type Hash and Range with a hash attribute Id and a range attribute ReplyDateTime.

You'll use this via the Query API, see RangeKeyCondition for details and Querying Tables in Amazon DynamoDB for respective examples.

can dynamo db give me all entries in which a field matches a certain number. [...] Can I ask dynamodb to give me all the entries which have value e.g. 6?

This is possible as well, albeit by means of the Scan API only (i.e. requires to read every item in the table indeed), see ScanFilter for details and Scanning Tables in Amazon DynamoDB for respective examples.

Do both of these queries need a scan of the entire dataset (which I assume is a problem given the dataset size?)

As mentioned the first approach works with a Query while the second requires a Scan, and Generally, a query operation is more efficient than a scan operation - this is a good advise to get started, though the details are more complex and depend on your use case, see section Scan and Query Performance within the Query and Scan in Amazon DynamoDB overview:

For quicker response times, design your tables in a way that can use the Query, Get, or BatchGetItem APIs, instead. Or, design your application to use scan operations in a way that minimizes the impact on your table's request rate. For more information, see Provisioned Throughput Guidelines in Amazon DynamoDB.

So, as usual when applying NoSQL solutions, you might need to adjust your architecture to accommodate these constraints.

这篇关于获取值了DynamoDB的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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