<legend id='bvc3s'><style id='bvc3s'><dir id='bvc3s'><q id='bvc3s'></q></dir></style></legend>

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

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

    • <bdo id='bvc3s'></bdo><ul id='bvc3s'></ul>
    1. <tfoot id='bvc3s'></tfoot>
    2. 如何获取 DynamoDB 表中的项目总数?

      How can I get the total number of items in a DynamoDB table?(如何获取 DynamoDB 表中的项目总数?)

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

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

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

          1. <tfoot id='TZfqa'></tfoot>

                <tbody id='TZfqa'></tbody>

                <bdo id='TZfqa'></bdo><ul id='TZfqa'></ul>
              • 本文介绍了如何获取 DynamoDB 表中的项目总数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想知道我的 dynamodb 表中有多少项目.从 API 指南中,一种方法是使用 scan 作为如下:

                I want to know how many items are in my dynamodb table. From the API guide, one way to do it is using a scan as follows:

                <?php
                $dynamodb = new AmazonDynamoDB();
                
                $scan_response = $dynamodb->scan(array(
                    'TableName' => 'ProductCatalog' 
                ));
                
                echo "Total number of items: ".count($scan_response->body->Items)."
                ";
                

                但是,这必须获取所有项目并将它们存储在内存中的数组中,这在我认为的大多数情况下是不可行的.有没有办法更有效地获取项目总数?

                However, this has to fetch all items and store them in an array in memory which isn't feasible in most cases I would presume. Is there a way to get the total item count more efficiently?

                此数据在 AWS Dynamo 网络控制台中不可用,我已经检查过了.(起初它看起来像显示在分页按钮旁边,但事实证明,随着您转到下一页项目,这个数字会变大).

                This data is not available in the AWS Dynamo web-console, I have already checked. (at first it looks like it is shown alongside the pagination buttons, but it turns out the figure grows as you go to the next page of items).

                推荐答案

                我可以想到三个选项来获取 DynamoDB 表中的项目总数.

                I can think of three options to get the total number of items in a DynamoDB table.

                1. 第一个选项是使用扫描,但扫描功能效率低下,通常是一种不好的做法,尤其是对于读取量大的表或生产表.

                1. The first option is using the scan, but the scan function is inefficient and is in general a bad practice, especially for tables with heavy reads or production tables.

                第二个选项是 Atharva 提到的:

                The second option is what was mention by Atharva:

                我想到的一个更好的解决方案是保持总此类表的项目计数在单独的表中,其中每个项目将具有表名称作为它的哈希键和项目总数在该表中,因为它是非关键属性.然后您可以保留此表通过使原子更新可能命名为TotalNumberOfItemsPerTable"更新操作以增加/减少项目的总计数特定的表.

                A better solution that comes to my mind is to maintain the total number of item counts for such tables in a separate table, where each item will have Table name as it's hash key and total number of items in that table as it's non-key attribute. You can then keep this Table possibly named "TotalNumberOfItemsPerTable" updated by making atomic update operations to increment/decrement the total item count for a particular table.

                唯一的问题是增量操作不是幂等的.因此,如果写入失败或您多次写入,这将反映在计数中.如果您需要精确定位,请改用条件更新.

                The only problem this is that increment operations are not idempotent. So if a write fails or you write more than once this will be reflected in the count. If you need pin-point accuracy, use a conditional update instead.

                最简单的解决方案是返回 ItemCount 的 DescribeTable.唯一的问题是计数不是最新的.计数每 6 小时更新一次.

                The simplest solution is the DescribeTable which returns ItemCount. The only issue is that the count isn't up to date. The count is updated every 6 hours.

                http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_DescribeTable.html

                这篇关于如何获取 DynamoDB 表中的项目总数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                • <bdo id='Flirm'></bdo><ul id='Flirm'></ul>
                    <tbody id='Flirm'></tbody>
                  <legend id='Flirm'><style id='Flirm'><dir id='Flirm'><q id='Flirm'></q></dir></style></legend>

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

                      1. <small id='Flirm'></small><noframes id='Flirm'>