• <tfoot id='8SSFL'></tfoot>
    1. <small id='8SSFL'></small><noframes id='8SSFL'>

      • <bdo id='8SSFL'></bdo><ul id='8SSFL'></ul>

      <i id='8SSFL'><tr id='8SSFL'><dt id='8SSFL'><q id='8SSFL'><span id='8SSFL'><b id='8SSFL'><form id='8SSFL'><ins id='8SSFL'></ins><ul id='8SSFL'></ul><sub id='8SSFL'></sub></form><legend id='8SSFL'></legend><bdo id='8SSFL'><pre id='8SSFL'><center id='8SSFL'></center></pre></bdo></b><th id='8SSFL'></th></span></q></dt></tr></i><div id='8SSFL'><tfoot id='8SSFL'></tfoot><dl id='8SSFL'><fieldset id='8SSFL'></fieldset></dl></div>

      1. <legend id='8SSFL'><style id='8SSFL'><dir id='8SSFL'><q id='8SSFL'></q></dir></style></legend>

        如何在不指定主键的情况下从 DynamoDB 表中获取所有项目?

        How can I fetch all items from a DynamoDB table without specifying the primary key?(如何在不指定主键的情况下从 DynamoDB 表中获取所有项目?)
        <i id='rI7I4'><tr id='rI7I4'><dt id='rI7I4'><q id='rI7I4'><span id='rI7I4'><b id='rI7I4'><form id='rI7I4'><ins id='rI7I4'></ins><ul id='rI7I4'></ul><sub id='rI7I4'></sub></form><legend id='rI7I4'></legend><bdo id='rI7I4'><pre id='rI7I4'><center id='rI7I4'></center></pre></bdo></b><th id='rI7I4'></th></span></q></dt></tr></i><div id='rI7I4'><tfoot id='rI7I4'></tfoot><dl id='rI7I4'><fieldset id='rI7I4'></fieldset></dl></div>
          • <bdo id='rI7I4'></bdo><ul id='rI7I4'></ul>
            <legend id='rI7I4'><style id='rI7I4'><dir id='rI7I4'><q id='rI7I4'></q></dir></style></legend>
                    <tbody id='rI7I4'></tbody>

                • <small id='rI7I4'></small><noframes id='rI7I4'>

                  <tfoot id='rI7I4'></tfoot>

                  本文介绍了如何在不指定主键的情况下从 DynamoDB 表中获取所有项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个名为 products 的表,主键为 Id.我想选择表中的所有项目.这是我正在使用的代码:

                  I have a table called products with primary key Id. I want to select all items in the table. This is the code is I'm using:

                  $batch_get_response = $dynamodb->batch_get_item(array(
                      'RequestItems' => array(
                  
                          'products' => array(
                              'Keys' => array(
                                  array( // Key #1
                                      'HashKeyElement'  => array( AmazonDynamoDB::TYPE_NUMBER => '1'),
                                      'RangeKeyElement' => array( AmazonDynamoDB::TYPE_NUMBER => $current_time),
                                  ),
                                  array( // Key #2
                                      'HashKeyElement'  => array( AmazonDynamoDB::TYPE_NUMBER => '2'),
                                      'RangeKeyElement' => array( AmazonDynamoDB::TYPE_NUMBER => $current_time),
                                  ),
                              )
                          )
                      )   
                  ));
                  

                  是否可以在不指定主键的情况下选择所有项目?我正在使用适用于 PHP 的 AWS 开发工具包.

                  Is it possible to select all items without specifying the primary key? I'm using the AWS SDK for PHP.

                  推荐答案

                  Amazon DynamoDB 提供 <为此目的的 href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_Scan.html" rel="noreferrer">Scan 操作,返回一个或多个项目,并且它的属性通过执行一个表的完整扫描.请注意以下两个限制:

                  Amazon DynamoDB provides the Scan operation for this purpose, which returns one or more items and its attributes by performing a full scan of a table. Please be aware of the following two constraints:

                  • 根据您的表格大小,您可能需要使用分页来检索整个结果集:

                  • Depending on your table size, you may need to use pagination to retrieve the entire result set:

                  注意
                  如果扫描的项目总数超过 1MB 限制,则扫描停止并将结果返回给用户LastEvaluatedKey 在后续操作中继续扫描.这结果还包括超出限制的项目数.扫描可能导致没有符合过滤条件的表数据.

                  Note
                  If the total number of scanned items exceeds the 1MB limit, the scan stops and results are returned to the user with a LastEvaluatedKey to continue the scan in a subsequent operation. The results also include the number of items exceeding the limit. A scan can result in no table data meeting the filter criteria.

                  结果集最终是一致的.

                • 就性能和消耗的容量单位(即价格)而言,扫描操作的成本可能很高,请参阅 扫描和查询性能部分.com/amazondynamodb/latest/developerguide/QueryAndScan.html" rel="noreferrer">在 Amazon DynamoDB 中查询和扫描:

                • The Scan operation is potentially costly regarding both performance and consumed capacity units (i.e. price), see section Scan and Query Performance in Query and Scan in Amazon DynamoDB:

                  [...] 此外,随着表的增长,扫描操作会变慢.扫描操作检查每个项目的请求值,可以用完在单个操作中为大型表提供的吞吐量.为了更快的响应时间,请以可以使用的方式设计您的表格Query、Get 或 BatchGetItem API.或者,设计您的应用程序以最小化影响的方式使用扫描操作在您的表的请求率上.有关详细信息,请参阅 已配置Amazon DynamoDB 中的吞吐量指南.[强调我的]

                  [...] Also, as a table grows, the scan operation slows. The scan operation examines every item for the requested values, and can use up the provisioned throughput for a large table in a single operation. 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. [emphasis mine]

                • 您可以在 使用扫描表中找到有关此操作的更多详细信息和一些示例片段适用于 Amazon DynamoDB 的 AWS SDK for PHP Low-Level API,最简单的示例说明了该操作:

                  You can find more details about this operation and some example snippets in Scanning Tables Using the AWS SDK for PHP Low-Level API for Amazon DynamoDB, with the most simple example illustrating the operation being:

                  $dynamodb = new AmazonDynamoDB();
                  
                  $scan_response = $dynamodb->scan(array(
                      'TableName' => 'ProductCatalog' 
                  ));
                  
                  foreach ($scan_response->body->Items as $item)
                  {
                      echo "<p><strong>Item Number:</strong>"
                           . (string) $item->Id->{AmazonDynamoDB::TYPE_NUMBER};
                      echo "<br><strong>Item Name: </strong>"
                           . (string) $item->Title->{AmazonDynamoDB::TYPE_STRING} ."</p>";
                  }
                  

                  这篇关于如何在不指定主键的情况下从 DynamoDB 表中获取所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How do I parse XML containing custom namespaces using SimpleXML?(如何使用 SimpleXML 解析包含自定义命名空间的 XML?)
                  SimpleXML SOAP response Namespace issues(SimpleXML SOAP 响应命名空间问题)
                  Problems with PHP namespaces and built-in classes, how to fix?(PHP 命名空间和内置类的问题,如何解决?)
                  Use php namespace inside function(在函数内部使用 php 命名空间)
                  unexpected #39;use#39; (T_USE) when trying to use composer(尝试使用作曲家时意外的“使用(T_USE))
                  PHP adding custom namespace using autoloader from composer(PHP使用来自作曲家的自动加载器添加自定义命名空间)

                    <i id='skdCY'><tr id='skdCY'><dt id='skdCY'><q id='skdCY'><span id='skdCY'><b id='skdCY'><form id='skdCY'><ins id='skdCY'></ins><ul id='skdCY'></ul><sub id='skdCY'></sub></form><legend id='skdCY'></legend><bdo id='skdCY'><pre id='skdCY'><center id='skdCY'></center></pre></bdo></b><th id='skdCY'></th></span></q></dt></tr></i><div id='skdCY'><tfoot id='skdCY'></tfoot><dl id='skdCY'><fieldset id='skdCY'></fieldset></dl></div>
                      <tbody id='skdCY'></tbody>

                      <small id='skdCY'></small><noframes id='skdCY'>

                      • <legend id='skdCY'><style id='skdCY'><dir id='skdCY'><q id='skdCY'></q></dir></style></legend>

                          <bdo id='skdCY'></bdo><ul id='skdCY'></ul>

                            <tfoot id='skdCY'></tfoot>